Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Not knowing how to catch Errors

 
Maganti Suryanarayana Murthy
Greenhorn
Posts: 10
Eclipse IDE Hibernate Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am using drools i.e., a fire engine. Instead of writing the business logic in java i am using text based rules. Everything is fine but i have doubt how to assign the error messages or warning messages to the corresponding object which i am inserting in session. I want to set the error messages to the pojo class so that in UI i can display it. Please find the code below.

Message.java



DefaultMessage.java



ValidationReport.java



DefaultValidationReport.java



ReportFactory.java



DefaultReportFactory.java



SecurityRules.drl File


ServiceImplementation class. The problem is here. I am not understanding how to set error messages to UserLogin Pojo class. I have written one logic please correct me. I think what i have written is not setting the error messages to pojo class.




the code is working fine. I am getting the errors also and i am uning the condition that if the size of errors > 0 dont call save or update method. Upto here no problem. The problem is how to set the error message to pojo class so that in UI i can display it.
 
Prabaharan Gopalan
Ranch Hand
Posts: 66
Java Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't go through the classes but I'm curious, why would you think this is a Java problem and not some configuration in Drools?
 
dennis deems
Ranch Hand
Posts: 808
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't recommend setting an attribute on the object that is passed to the service. Better to return a collection of Messages from the service method. Also create a custom exception class that allows you to set your Message objects on it -- but be careful to differentiate these from the message attribute on the Throwable class. When you throw an exception, throw your custom exception type with the messages populated.
 
Maganti Suryanarayana Murthy
Greenhorn
Posts: 10
Eclipse IDE Hibernate Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can able to return the collection of messages in the service class. But the problem is that i want to set those messages to Object as it should be passed to VO.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic