Customised validation in jsf

hi,
pls help
my requirement is that, in the case of implementing customised validation in jsf ,i have to call an xml(which is outside of our application context ) in backing bean's method using java unified expression laguage . i'm not able to parse and read this xml's data using expression language.
please send code.

I should not used the hx library.So,please give a soluntion other than this.
Message was edited by:
Yamini_screen

Similar Messages

  • Validation in JSF using alert boxex with javascript

    Hi,
    I want to validate the input of the user as client-side validation, without returning to the server..
    So, if for example he doesn't fill in a field, an alert box should be displayed : " No valid input !!"
    Can soemone help me..
    Thanks

    <h:selectOneRadio id="myradio" required="true" ... >
    </h:selectOneRadio>
    <h:message for="myradio" />Submit the form, if the radio is not selected while the 'required' attribute is set to true, you will get a default validation error in the h:message.
    Get through a good JSF book/tutorial and read on about the validation. JSF offers a robust and highly customizeable validation framework. The error messages are also customizeable. The only difference with the Javascript approach is that it costs one trip to the server as well. But the big advantage is that it is much more robust. As Javascript is clientside, it can easily be disabled by the client or even hacked by the client.
    Here are some useful links:
    JSF book: http://www.amazon.com/JavaServer-Faces-Complete-Reference/dp/0072262400
    JSF specification: http://jcp.org/aboutJava/communityprocess/final/jsr252/index.html
    JSF tutorial (Java EE tut chapter 10 and on): http://java.sun.com/javaee/5/docs/tutorial/doc/bnaph.html

  • How to do Javascript validations in JSF

    Hi ,
    I want to know about the javascript validation in JSF. I want to know simple validations like field should not be empty.
    I have a problem with my code can any one suggest me on this. for your reference here i'm attaching my code.
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
    <f:view>
         <%@ include file="../includes/header.jsp"%>
         <h:form id="createForm">
              <script>   
             function validate() { 
                 if((document.createForm.courseId.value=='') ||(document.createForm.courseId.value==null))
                    alert("Please Enter Course Id");     
                     return false; 
                 if(document.createForm.fileName.value=='')
                    alert("Please Enter File Name");     
                     return false; 
                   retutrn true;
                         </script>
              <table width="768" height="100%" border="0" cellpadding="0"
                   cellspacing="0">
                                  <tr>
                                                      <td width="200" height="25" align="left" class="formtext">
                                                           Course Id:
                                                      </td>
                                                      <td height="25" align="left">
                                                           <h:inputText id="courseId"  value="#{bean.courseId}"  required="true"  />
                                                      </td>
                                                 </tr>
                                                 <tr>
                                                      <td width="200" height="25" align="left" class="formtext">
                                                           File Name:
                                                      </td>
                                                      <td height="25" align="left">
                                                           <h:inputText id="fileName" value="#{bean.fileName}" />
                                                      </td>
                                                 </tr>
                                            </table>
                                  <tr>
                                       <td colspan="2" align="center" class="formtext">
                                            <h:commandButton value="Create"
                                                 action="#{control.getSelectedItems}"
                                                 onclick=" return validate();" />
                                       </td>
                                  </tr>
                             </table>
                        </td>
                        <td width="12" valign="top" background="images/tile_left_right.jpg">
                             <img src="images/tile_left_right.jpg" width="6" height="1" />
                        </td>
                   </tr>
              </table>
         </h:form>
         <%@ include file="../includes/footer.jsp"%>
    </f:view>

    Have you checked the element ID's? Maybe you have overlooked the woodstocked ID's. Look in the generated HTML source and base your Javascript on this.

  • Issue with back end validation in jsf 2.0

    I am upgrading my apps to jsf2.0 and I came across something that I hope you have already solved.
    In jsf 1.1 action methods returned a string. If that string was NOT mapped as a navigation in faces-config.xml, then it just rerendered the active page. this made doing back end validation easy because I could add messages to the faces context and when the active page rerendered the validation messages would get displayed and no one was the wiser than it was done on the back end instead of on the front end.
    In jsf 2.0 I get null pointers if I return a string that is NOT mapped as a navigation. So I changed the code to return a string that is mapped as a navigation for that page when there is a validation error. but that is treating it like a new request and not a rerender so the validation messages I added to the faces context are not there when the page renders.
    if i test submit a form that has only front end validation then it works fine and the validation messages are correctly shown.
    any suggestions?

    In 11.2.0.3 you are unlikely to see the various truncate/drop issues relating to large numbers of small extents - unless you use dictionary managed tablespaces.
    There are a couple of possible threats with small extents and highly concurrent inserts with ASSM that might be a temporary problem when the object size is small. There may still be some issues with large uncommitted inserts or deletes making other session's work very hard to identify free blocks until the large transaction has committed - these things can be hard to test.
    There may still be a couple of inefficiencies with parallel query and small extents, although parallel CTAS did have a (possibly temporary) hack to allocate immediate large extents to work around some of the silly details.
    Really you need to think through your requirements and them model them on your system - some of the anomalies have changed several times over the last three years.
    Regards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    Now on Twitter: @jloracle

  • How to make custom  validator in jsf

    hi
    i am using jsf for web designing in my projects.now we are using java script for JSF validation .but i am interested to do validation using validator tag of JSF.i have tried ,but it is not working.what can i do for this problem.can u give some simple examples with clear explanations.
    My validator class file is
    package com.obs.ftw.util.validation;
    public class isEmpty implements Validator{
         public isEmpty(){}
         public void validate(FacesContext context, UIComponent uiComponent,Object value) throws ValidatorException{
              System.out.println("Inside the validate");
    FacesContext context=new FacesContext();
              String firstName=(String)value;
              if(StringUtils.isEmpty(firstName)){
                   FacesMessage message=new FacesMessage();
                   message.setSeverity(FacesMessage.SEVERITY_ERROR);
                   message.setSummary("First Name is Empty");
                   message.setDetail("First Name is Empty");
                   context.addMessage("Application:T5",message);
    faces-config is
    <validator>
              <validator-id>isEmpty</validator-id>
              <validator-class>com.obs.ftw.util.validation.isEmpty</validator-class>     
         </validator>
    jsf page is
    <h:message for="T5"></h:message>
    <h:inputText value=#{mybean.lcFirstname} id="T5" required="true">
    <f:validator validatorId="isEmpty"/>
    </h:inputText>
    this function calls isEmpty constructor.but system.out.println("Hi") isn't called which is defined inside the validate()
    fuction.
    any problem in this isEmpty function?any one give me a solution with an example
    advance thanks
    with regards
    oasisdeserts

    Thanks for reply.i was expecting this one and it is working fine .but i want to validate null or empty string using
    validator tag.Is any other way to do this .There is no standard way to do this. You may consider to write your own implementation of the JSF LifeCycle.
    can u give some explanation to create messagebundle Check chapter 2.5.2.4 of the JSF specification: [http://jcp.org/aboutJava/communityprocess/final/jsr252/index.html]
    whether it will be useful to validate empty string?The default behaviour is:
    The 'required' attribute already validates the empty value. If the value is empty and the 'required' attribute is set to true, then the "field is required" message will show up (text may depend on the message settings and configuration -- in JSF 1.2 you can use the 'requiredMessage' attribute to specify that message right in the JSF page). If the value is not empty, then the attached validator will be fired, regardless of the setting of the 'required' attribute. If the value is empty and the 'required' attribute is false or not set, then no validation will be taken place.jsf

  • How to implement JavaScript validation in JSF

    Dear all,
    if i wish to implement JavaScript front end validation function in JSF. what should i do?
    thanks.

    Hi,
    in Core JSF from David Geary there is a chapter on using
    Jakarta Commons Validator for javaScript validation
    source could be found here:
    http://www.horstmann.com/corejsf/
    HTH,
    Matthias

  • About Validation in JSF

    i encounter such a problem that: when a jsf page fails in validation, i cannot do anything on that page till validation success or i kill the session. For example when i fill a field with an inappropriate value, it fails in validation. then i send another parameter to that page which is appropriate to the scope of validation. then the jsf page refreshes but the value that caused the validation failed is rendered not the parametre i sent. when i asked it to the senior developers they said it is such the way. they said the wrong value kept somehow. if u share your knowledge i will be appreciate. santiago

    you can create a demo use JSF achitecture, and create the simple page,
    for example ,login.jsp, and add tag <h:inputText/> <h:commandButton/> in you login page,
    add custom validation and custom converter to <h:inputText/>
    for your tag <h:commandButton/>, adding the phaseListener and track the JSF lifeCycle by log4j.
    you will learn more about component-based JSF achitecture.
    ...

  • Customising validation alert window

    Hi,
    I wondered if someone could tell me if it's possible to customise the output of validation errors that appear in the alert popup if required fields are not completed?
    I assume that I'd have to edit the file at the following path:
    CatalystScripts/ValidationFunctions.js
    If yes, can anyone tell me where that file is located in the site structure.
    Thanks in advance.

    Thanks for the link,
    The problem is that it only lets you customise certain alert messages (related to an online store) whereas I need a way to customise specific messages related to my custom form. Do you know if there is another way to do this?

  • Form getting submitted even A4j validation fails +jsf

    i am using a4j for checking username exists or not for onblur event
    it displays the error messages when user already exists but ,if i click on
    submit button after displaying the error message it gets submitted
    when it comes to the required=true for inputtext it doesn't get submitted
    <h:inputText id="firstName" label="#{msg['msg.firstName']}"
                                                            value="#{RegistrationBean.firstName}"                                                        
                                                            required="true" validator="#{RegistrationBean.checkFirstName}">
                                                            <a4j:support event="onblur" reRender="msg" onsubmit="true" oncomplete="true" />                                 
                                                         </h:inputText>
    public void checkFirstName(FacesContext facesContext, UIComponent component, Object value) 
              String name = (String) value;
             if(name.trim().length()==0){
                  System.out.println("Name *******");
                  String message = bundle.getString("Name_Required");
                   FacesContext.getCurrentInstance().addMessage("Reg:firstName",
                         new FacesMessage(FacesMessage.SEVERITY_ERROR, message,message));                    
             if(name.trim().equalsIgnoreCase("tom")){
                  String message = bundle.getString("Name_exists");
                   FacesContext.getCurrentInstance().addMessage("Reg:firstName",
                         new FacesMessage(FacesMessage.SEVERITY_ERROR, message,message));                    
           }could anyone suggest me where i went wrong
    thanks

    bean is configured as request in faces-config and also tried changing to session

  • How to avoid page validation in JSF / ADF

    In my form I have "cancel" button ( type="reset" ). But when I press it, validation started. But I don't need validation when this button pressed.
    What I can do to avoid validation ?

    You should set the immediate="true" attribute.
    Regards,
    Kati

  • Date Validation in JSF & Richfaces

    I m using a rich:calendar to display Date in my application
    But some how date validation isn't working properly in a particular scenario.
    i.e it some one enters date as 05/05/2010sfc in this case it automatically trims the extra characters in the end
    and displays date properly in next page instead of giving an error of invalid date on same page.
    It works in other cases such as asd05/05/2010, 05sfa/05/2010, etc
    I tried using <f:convertDateTime> but it didn't help :(
    Can anyone please help me on this...

    The date correction is done based on the pattern date you use and it's done on the client. <f:convertDateTime> is called on the server. It's still called but produces no conversation error as the value is correct. Also, <f:convertDateTime> is converter, not validator.
    Hope this helps...
    Max
    [http://mkblog.exadel.com]

  • Validations in JSF

    Hi All,
    I have 4 input fields in my JSP. Atleast one is required and not all are mandatory. So i have added a hidden input field and written a custom validator that is called for every submit.
    For a particular field, i have a validation for numbers. I do this using the Shale validator's "mask". And in the custom component i validate for zeroes.
    Now if i give the input as "aaaaaaa", then the error message from "mask" is displayed. If i now enter "0000000", then the validation message from custom component is displayed. Now after this, if i enter "aaaaaaa", it shows both messages.
    the reason is that i have used UIInput.getValue() in my custom component. The getValue() is "0000000" and UIInput.getSubmittedValue() is "aaaaaaa". Why is the previous input retained?
    Can someone provide a solution?

    abhi004 wrote:
    I tried using the attribute readonly="true", but I am losing the data held by these fields from the corresponding bean when I click submit.Then there's a bug somewhere. This behaviour (losing value) should only occur when you used the disabled attribute. The readonly attribute should still send the value to the server side.

  • Validation in jsf

    I have a h:inputText in my JSP. I have associated the value of this component with a backing bean property of type Double.
    If input contains letters then I need to call a method in the backing bean and set the appropriate rendering flag and display the message.
    But the action method is not called if a letter is entered, I guess this is because of the life cycle where conversion - validation - action takes place.
    Hence it fails in the conversion phase. How can I call a backing bean method during conversion phase?
    Regards,
    Joshua

    If you want to allow letters in a Double, use String instead of Double then.
    I guess this is because of the life cycle where conversion - validation - action takes place.Are you using h:message by the way? I can't see how you can guess when a clear conversion error message just shows up.

  • Validation in  JSF component

    Hello,
    I've useded the following tuturial(with changes) in order to implement validation.
    http://today.java.net/pub/a/today/2004/07/16/jsfcustom.html
    But, unfortonetly, the code doesn't arrive this point of tuturial - of validation, after posting.
    I'm working in RAD- with websphear 6.
    Please help me understand the reason
    thanks,
    Avi.

    up

  • Number Validation in jsf  Issue

    I am new to jsf
    I have a text box in which user can enter only number i done the validtion for it..
    It displays...
    value must be an integer number between -2147483648 and 2147483647
    But i want ot display only 'value must be integer' i want to omit the rest of the part..
    I tried
    <h:inputText value="#{employee.age}" required="true" requiredMessage="Value must be integer"
    <f:validateLongRange minimum="0 maixmum="100" />
    </h:inputText>
    Please suggest the solution for it please
    shashi

    santigo wrote:
    You can find the .properties file and change the message. But i do not recommend it to u.Why not? You're free to customize any general error messages. You're not forced to use the standard error messages.
    but you can write your custom validater.Too much more work than simply creating a propertiesfile with a single line in it, putting it in the classpath and specifying it in the faces-config.xml.

Maybe you are looking for