Announcement Announcement Module
Collapse
No announcement yet.
SWF2 equivalent: Errors getFormErrors() of SWF1 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • SWF2 equivalent: Errors getFormErrors() of SWF1

    before SWF1 I am using getFormErrors() to get the Errors object..

    anybody knows the equivalent in SWF2?

  • #2
    Can you describe how you're trying to use the errors? Are you trying to add new errors in? Are you trying to programatically access the errors in your Java code, for some reason? Or are you trying to display the errors on your page? Also, it helps to know what frameworks you're working with. Spring MVC, or JSF?

    Comment


    • #3
      thanks Sir...

      Main goal is to handle the business exception and exception (other than business)..

      have no idea on how to implement exception handling inside the business logic classes..

      right now,

      1) I added ErrorList in my Domain...

      2.1) when business logic error occurs, domain.addError(fieldName, errorCode) to gather all business logic error only.

      e.g.

      Business Logic Class
      // 10 & 100 were validated within validator class
      // then the result has 3 digits condition
      // then the condition need to validate inside the business logic class
      10 x 100 = 1000

      if (1000 > 3 digits) {
      domain.addError(fieldName, errorCode)
      }

      Service Class
      // I have putErrors(messageContext, domain) in order to check and add the error messages in the messageContext.
      2.2) when business exception and exception occurs..
      e.g.

      Business Logic Class
      // I created BusinessException class
      try {

      // via throw or exception occured

      } catch (BusinessException be) {
      domain.addError(errorCode);

      } catch (xxxxException xxxxEx) {
      domain.addError(errorCode);

      } catch (Exception ex) {
      domain.addError(errorCode);

      }

      Service Class
      // I have putErrors(messageContext, domain) in order to check and add the error messages in the messageContext.
      if you have best ideas on how to implement the error handling.. please guide me on...

      Comment


      • #4
        Originally posted by InverseFalcon View Post
        Or are you trying to display the errors on your page? Also, it helps to know what frameworks you're working with. Spring MVC, or JSF?
        yes sir.. I am trying to display the errors on my page...

        Spring MVC 2.5.6.SEC01
        Spring Webflow 2.0.8.RELEASE
        JSP

        Comment


        • #5
          I haven't worked with Spring MVC directly, but I imagine you would use some kind of error tag provided by the framework.

          As for getting the errors into the MessageContext, you should be able to do this as described in the reference guide. Also see the section on working with messages.

          It looks like you already have a service class set up to abstract away the dependency on MessageContext, which should work fine. I'm not exactly sure what you're asking for in regards to how you're currently handling and storing the exceptions. Can you be a bit more specific?

          Comment


          • #6
            I see... I will post my solution... thanks a lot..

            One more thing, if you allows me,...

            it is possible to get the Errors object from SWF ValidationContext?

            Code:
            e.g.
            @Component
            public class Model1Validator extends CommonValidator {
            
            	public void validateEnterFlow1(Model1 model1, ValidationContext context) {
            		
            		MessageContext messages = context.getMessageContext();
            		
            		String userEvent = context.getUserEvent();
            		
            		Principal userPrincipal = context.getUserPrincipal();
            		
            		Object userValue = context.getUserValue("analyzeId");
            		
            		//would like to use the ValidatioUtils but don't know how to provide the Errors object
            		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "analyzeId", "EVY100000", new Object[] {"Analyze"} , DEFAULT_MESSAGE);
            		
            		messages.addMessage(new MessageBuilder().error().source("analyzeId").code("EVY100000").args(new Object[] {"Analyze"}).defaultText(DEFAULT_MESSAGE).build());
            		
            
            	}
            
            }

            Comment


            • #7
              Not sure, I haven't dealt with the validation context. I think it's more widely used with SpringMVC than with JSF.

              Comment


              • #8
                Originally posted by InverseFalcon View Post
                Not sure, I haven't dealt with the validation context. I think it's more widely used with SpringMVC than with JSF.
                yes Sir, I am fun of Spring and want to use all the Spring's available functionality... and also i've noticed that smoothly integrated with JSF rather than JSP...

                on my next project... will use JSF as view technology..

                Comment


                • #9
                  my temporary solution is to create a ValidationUtils that having same functionality with Spring's ValidationUtils..

                  but anyone who knows how to implement the above specifications ..
                  please guide me on.. thanks a lot..

                  Comment

                  Working...
                  X