Skip to Content
author's profile photo Former Member
Former Member

Validating user input in bean

Hi All,

I created a new xhtml page with input fields of datatype alpha-numeric, email etc in a panel grid and also created a managed bean.

In order to validate the user input, in xhtml page i registered PostValidateEvent system event in the panel grid which contains all the input fields

<f:event listener="#{beanName.validateFields}" type="postValidate" />

and a “listener” method with signature public void method-name(ComponentSystemEvent event) in the bean.

public void validateFields((ComponentSystemEvent event){

// field validations

}

I didnot get any build or deploy error related to the event registered. But the postvalidate event is not triggered and validation is not done.

Please help me to validate the user inputs in the bean.

Thanks,

Nithya

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Posted on Feb 18, 2013 at 06:51 PM

    Hi Nithya,

    where did you place the <f:event> tag?

    Did you debug or how did you make sure that your method is getting called?

    Are you using WCEM 2.0?

    Regards,

    Elena

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Elena,

      Thanks for your interest in helping me.

      I am using WCEM 2.0. I placed <f:event> tag within <wec:panelGrid> which contains all the components i need to validate. when i debug, the control is not breaking in validateField(

      ComponentSystemEvent event) method, which means postValidateevent is not getting triggered.

      Please let me know is there any alternative way to validate input data?

      Regards,

      Nithya

  • author's profile photo Former Member
    Former Member
    Posted on Feb 18, 2013 at 08:07 PM

    Hi Nithya

    Can you check the below link, hope it will help you?

    http://www.mkyong.com/jsf2/multi-components-validator-in-jsf-2-0/

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi,

      I dont have NWDS open to check - could it be due the fact you have JSF 2.0 and the "type" was introduced in 2.1?

      I'm not too sure if I have ever used it before in WCEM - I would suggest you override the impl. supplied by SAP with your own DC/SDA containing the latest impl. plus latest el-api/impl too.

      Please let me know once you have tried.

      D.

  • author's profile photo Former Member
    Former Member
    Posted on Mar 07, 2013 at 08:27 AM

    Hi Nithya,

    I have just tried your event listener coding in an example Web Channel Application and it works perfect.

    I assume, that something with your DC setup is not correct. To ensure, that JSF 2 is working correct, the following preconditions have to be fulfilled:

    1. The developemnt component wec/frw/tc/jsf/libsrv has to be deployed.
      This contains the JSF 2 implementation for the Java EE.
    2. A hard reference
      <reference reference-type="hard" prepend="true">
      sap.com"
      target-type="library">wec~frw~tc~jsf~lib</reference-target>
      </reference>
      has to be included in the application-j2ee-engine.xml file of the
      application and into the application-j2ee-engine.xml file of the
      modules, that are using JSF functionality. This ensures, that the
      deployment units can access the JSF 2 implementation on the server.
    3. A DC dependency to engine.jee5.facade with public part
      "apiwithoutjsf" has to be included into the modules ui part. The public
      part "api" must not be included. This ensures, that the code is not
      linked against the JSF 1.2 api of the engine.
    4. A DC dependency to wec/frw/tc/jsf/lib with public part "api" has to
      be included into the modules ui part. This makes the JSF 2 api available
      for the module.

    Please check, if all these preconditions are fulfilled. I assume, that 3. and/or 4. are not fulfilled.

    Please keep me informed, if this solves the problem.

    Ralf

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.