JSF Validator Lifecycle

Hi all,
I'm planning to check the username and password using jsf validator, however I'm a bit worry about the security when passing the value to the server. Will the value exposed when the validator is called?
At first I planned to do some hashing before it transfer to server, however if it's hashed, then validation cannot be done, since the value already hashed.
Any suggestion?
Thanks.

The validate() method accepts the UIComponent being validated, in this case the <h:inputText>. Use the UIInput.resetValue() method on it.

Similar Messages

  • JHS and JSF Validation Conversion Error Customizations

    Hello
    Have JHS done any work about JSF validation or conversion error customizations?
    I mean the error messages such as "lablename:"value mus be entered etc.
    What can i do if i want to globally customize and localize this error messages.
    I have copied the key such as "javax.faces.component.UIInput.REQUIRED" in my appdeff resource bundle but JHS (or maybe ADF) gives own message yet.
    I Apologize if my problem don't depend on JHS. I wonder that JHS overrided JSF default messages.
    Thank You

    JHeadstart does not use any JSF standard message.
    JHeadstart uses ADF Faces which comes with its own bundle of error messages.
    Please use the JDeveloper forum for instructions on modifying ADF Faces error messages.
    Steven Davelaar,
    JHeadstart Team.

  • Skip JSF validation

    Hi,
    I have 1 form with 1 commanButton and 1 commanLink. Each form element has some validation set, e.g. required=true. When the commandButton is clicked I want to do this JSF-validation, but when the commandLink is clicked I would like to skip it. Is that possible to do in an easy way?
    Regards
    Pichdude

    Yes, very easy to do. Add the immediate="true" attribute to the commandLink.
    CowKing

  • JSF Validation failure causes input values disappear

    I am using a custom validator in my application by creating a class that implements javax.faces.validator.Validator. I use this validator for some input fields. When the validation fails the values that the user has entered are lost. Is their any way that we can keep these values? These input fields are in DataTable.
    - Sandeep.
    Edited by: sgatl2 on Mar 24, 2010 10:41 AM

    If you see the JSF lifecycle, the validation phase comes before the update values phase.
    So if your custome validator fails, the model will not change.
    I would suggest you try with client side validation without a page refresh/server call.

  • Doubts abour JSF proccesing lifecycle and JSF phases

    Hi,
    I have doubts about the processing lifecycle of a JSF application if there are two different requests from the same user. For example, suppose an application with two buttons:
    Button 1 --> A load button connected to a actionListener method that load a lot of data from data base that will be showed in a table.
    Button 2 --> A Cancel button with immediate=true and connected to a action method that force a navigation to the same page when is pressed.
    Suppose the following sequence:
    1 -. User press button 1, I think that the following phases are executed:
    Request View --> Apply Request Values --> Proccess Validation --> Update model Values --> Invoke Application (in this phase the actionListener method is executed to load the data from database) --> Render Response (take long time)
    2-. Due to a big quantity of data the Render Response take long time and when the lifecycle is in that phase the user press the button 2. I suppose that the following sequence of phases are executed:
    Request View --> Apply Request Values -->Invoke Application (Action method that return a navigation case) --> Render Response (Render the page to the user)
    My question is, if the first request is in the Render Response phase, what happens with this phase when the second request generated by the Button 2 arrive to the server??? When the second request arrive to the server, JFS automatically cancel or stop the proccesing of the Render Response of the first request ?
    Thank you for your knowledge.

    It's always helpful to configure a "debugging" lifecycle listener that just prints out each lifecycle phase, so you can tell which phases are being executed, and in which phase some breakpoint is hit.
    This is as simple as:
    package tabpanelbug;
    import javax.faces.event.PhaseEvent;
    import javax.faces.event.PhaseId;
    import javax.faces.event.PhaseListener;
    public class LifeCycleListener implements PhaseListener
        public void beforePhase(PhaseEvent event)
        { System.out.println("BeforePhase: " + event.getPhaseId()); }
        public void afterPhase(PhaseEvent event)
        { System.out.println("AfterPhase: " + event.getPhaseId()); }
        public PhaseId getPhaseId()
        { return PhaseId.ANY_PHASE; }
    }and
    <lifecycle>
        <phase-listener>tabpanelbug.LifeCycleListener</phase-listener>
    </lifecycle>

  • Jsf validation

    Hi ,
    I have got a problem here.Please help me solve this.
    So its like this:
    I have one jsp(jsf)page , it has many validators .and some validation i did manually in action method.
    So the problem comes when validating when i clicked the save button first all the page level validation are validated and after giving correct value and saving again the validation message i gave are coming . So how can i get all message at a time.
    Thanks

    You can try this quick-and-dirty example:
    <h:messages globalOnly="true">
       <h:message for="tag1" />
       <f:verbatim><br/></f:verbatim>
       <h:message for="tag2" />
       ... // add other messages here
    </h:messages>Where tag1 and tag2 are id/name of your JSF tags on your form. However, I'm new to JSF so this may not be a best solution for you. You could give it a try and see how you go -:)

  • Is it possible to use a JSF Validator to perform a Dependency validation?

    I'm new to JSF, but getting more and more experience everyday. I've create some custom validators for a few input fields on my form and they are working beautifully. What I can't figure out is how to write a validator that will check a field for a value based on another fields value. For instance, I would like to require a person to enter an address if they select a Yes / No select box indicating they would like to supply an address.
    Does anyone know how I can do this? I've come up with a clunky work around by performing my dependency validations in my action page rather than a validator.
    Thanks!!!!

    Hi RaymondDeCampo.
    I have never been a big fan of how JSF (and even Struts)handle forms both in the front (the view) and the back.
    Forcing the developer to contend with writing a java class for each thinkable form does not look like a workable pattern to me. And tying the view (JSP or JSF page) tightly to the form classes and validators is also cumbersome.
    In many decent applications, the number of forms grows to more than a tiny handful and so would the number of classes that simply act as dummy data carriers.
    I do not see why I should have to maintain all the accompanying classes and validators and JSP code that each form comes with. Making changes to the structure of a form (say adding new fields or removing others, or even adding whole form pages into the sequence), modifying the model of a form (like renaming fields, adding new validation rules), or changing form view (e.g. switching from a list of checkboxes to a select dropdown, changing how and where error messages are presented, supporting a new language) are just some of those things that become tedious to maintain sentrally.
    No other model of building forms out there makes the named tasks any simpler, aprt from adding a new level of complexity to the simple data collection purpose of web forms. Well, except Formular. I have had Formular working in JSF and Struts although I ended up ditching the JSF way of handling forms altogether.
    I prefer good and solid separation of form components as outlined by Formular. Formular is the only API out that would allow me to migrate my forms from any Java web server to another without having to rewrite a line of code. Try upgrading your Struts form to JSF or vise versa and you'll get the idea of why I dropped the more hardwired way of coding web forms.
    With Formular, I have created a repository of validators (for doing my form checks). datasources (for populating lists, radios, checkboxes, and combos), and styles (for laying out my form elements). Making modifications to my repositories, I can do site-wide changes without touching my JSPs or Java classes. I can move form messages from the top of ALL my forms and place them just above the offending fields in one single style file, I can swap the markers on optional fields and use them only on required fields if the business manager wants to in a single go, I can even change validation rules that are attached to several fields in different web forms at one instance (how many hours did we save when one client wanted all buttons in the site changed to GIFs and all phone and address fields in their application and survey forms validated a little different?)
    Ack! Now It looks like I'm preaching, again so I'll hold myself.

  • JSF Validations & Hibernate cglib

    Hi,
    I'm having some trouble with using Hibernate with JSF.
    When using hibernate, lazy loaded.
    The problem is that i now have a CGLIB-enhanced version of one of my domain objects. The value of which is to be compared to a list of selectitems.
    As it turns out, JSF tries casting my normal objects to a version of those EnhancedObjects, which gives me an IllegalArgumentException because of course the Parent class (ConfigProfile) cannot be cast to one of it's children (ConfigProfile$$EnhancerByCGLibxxx$$)
    Has anyone ever come across this problem, and knows how to handle it ?
    Thanks in advance !
    Jeroen
    My Exception :
    12-jan-2007 11:18:14 com.sun.faces.lifecycle.ProcessValidationsPhase execute
    WARNING: Cannot convert com.watchtalk.web.businessobject.ConnectProfile@966905 of type class com.watchtalk.web.businessobject.ConnectProfile to class com.watchtalk.web.businessobject.ConnectProfile$$EnhancerByCGLIB$$b8f981a2
    java.lang.IllegalArgumentException: Cannot convert com.watchtalk.web.businessobject.ConnectProfile@966905 of type class com.watchtalk.web.businessobject.ConnectProfile to class com.watchtalk.web.businessobject.ConnectProfile$$EnhancerByCGLIB$$b8f981a2
         at com.sun.el.lang.ELSupport.coerceToType(ELSupport.java:367)
         at com.sun.el.ExpressionFactoryImpl.coerceToType(ExpressionFactoryImpl.java:52)
         at javax.faces.component.UISelectOne.matchValue(Unknown Source)
         at javax.faces.component.UISelectOne.validateValue(Unknown Source)
         at javax.faces.component.UIInput.validate(Unknown Source)
         at javax.faces.component.UIInput.executeValidate(Unknown Source)
         at javax.faces.component.UIInput.processValidators(Unknown Source)
         at javax.faces.component.UIForm.processValidators(Unknown Source)
         at javax.faces.component.UIComponentBase.processValidators(Unknown Source)
         at javax.faces.component.UIViewRoot.processValidators(Unknown Source)
         at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(Unknown Source)
         at com.sun.faces.lifecycle.LifecycleImpl.phase(Unknown Source)
         at com.sun.faces.lifecycle.LifecycleImpl.execute(Unknown Source)
         at javax.faces.webapp.FacesServlet.service(Unknown Source)

    In my case the exception was from expr.setValue(el, bo), where the Object before was a CGLIB-Proxy and the new Class wasn't. The Solution was to set the value NULL, before set the new Object.
    FacesContext context = FacesContext.getCurrentInstance();
    ELContext el = context.getELContext();
    ExpressionFactory ef = context.getApplication().getExpressionFactory();
    ValueExpression expr = ef.createValueExpression(el, "${Businessobject}", Businessobject.class);
    Service service = (Service) getBeanFromContext(service);
    Businessobject bo = service.createBusinessobject();
    expr.setValue(el, null);
    expr.setValue(el, bo);
    I hope this will be helpful for you.

  • JSF Validation -Javascript

    Hai All ,
    I would like to introduce "Client side Validation" in to my JSF Application . What now i am doing is that i just simple write 'required=true" attribute in my all jsf component whichever component value i need to validate before going to next phase . i feel that this server side validation . what i want do is that i want write one common java script file for all jsp page which can be validated all jsp page before sending data to server.
    If you any idea please share with me
    Selvakumar.

    There are several javascript libraries available on the net that do this but be careful. Server side validation is always more secure unless you want to compare client side validation with server side validation to catch an attempted hack.

  • How to obtain JSF Validation Messages Key?

    When a validation error occurs an error message component placed next to the component displays the message like "validation error:value is required".
    I know how to customize this message by having ur own resourece bundles. But i have this new requirement where i need to find not the message but the key corresponding to the message like 'javax.faces.component.UIInput.REQUIRED'.
    But when i look at the FacesMessage API all it has is summary and detail and no way to get this key of what hapenned. Is there anyway to do this using JSF API that iam unaware of or is it not possible at all?

    I knew how to customize the messages and the key. All i wanted to know is if i have an API that i cud use to find out the error key like javax.faces.UIInput.REQUIRED from a given FacesMessage instance?

  • JSF Validator option disables my submit functionality

    Hi,
    I introduced a Validator in an InputBox, which is tied with the Backing Bean validation method. After this inclusion, the validation method is getting invoked, but the submit is not getting invoked. Before introducing this validation, the page submit was working fine. Now if I remove the validation, then also the page submit is working.
    So somewhere the validation stops the page submit.
    Please help me to resolve this issue.
    ..Thiruppathy.R

    Yes. My validation runs as expected.
    If I supply an invalid value, then I am able to see the error message in the page which is thru <h:messages/>.
    If I pass a valid value, then neither I am able to see any error message nor the page is submitted.
    My jsf code is
    <h:inputText accesskey = "true" id="Login_Name"  value="#{LoginBean.loginName}" styleClass="login_input"
         validator="#{LoginBean.defaultValidator}" required="true">
         <f:validateLength  maximum="35"/> 
    </h:inputText>
    <h:commandButton value="Submit" style="margin-left: 15px; margin-top: 8px;" action="#{LoginBean.submit}" image="../images/btn_continue.jpg"> My Backing Bean validator is
         public void defaultValidator(FacesContext context, UIComponent component, Object value) {
              System.out.println("value::"+value);
              if (value != null) {
                   if (value.equals("admin1")) {
                        System.out.println("It matches with 'admin1'");
                        return;
              ((UIInput)value).setValid(false);
              FacesMessage msg = new FacesMessage("I am a real exception");
              context.addMessage(component.getClientId(context), msg);
         }As per this code, 'admin1' is the only valid value. But even if I give the value 'admin1', the page is not getting submitted.
    Please help me to find where I am wrong.
    Thanks
    Thiruppathy.R

  • JSF Validations

    Hi All,
    I am just started learning JSF [ 3 days old in JSF]. i was trying to do validation,it was giving me the follwing error.
    Conversion Error setting value '' for 'null Converter'.
    My JSP Code
    <h:message for="inputText1" styleClass="warning"/>
    <h:inputText id="inputText1" value="#{backing_login.inputText1}"
    validator="#{backing_login.validateFields}" required="true"/>
    BackingBean Code
    public String validateFields(FacesContext context,UIComponent toValidate,Object value)
    String val1 = (String) value;
    System.out.println("inside Validate Fields");
    if (val1.equalsIgnoreCase("") || val1.length() ==0)
    ((UIInput)toValidate).setValid(false);
    FacesMessage message = new FacesMessage();
    // message.setDetail("Some Required fields are Blank..");
    context.addMessage(toValidate.getClientId(context), message);
    return "error";
    Can any one please help me on this.
    Thanks in Advance.
    Arthi

    Thanks for the reply.
    In the Backing bean i defined inputText1 as
    private HtmlInputText inputText1;If you want to bind the component with the backing bean, use the 'binding' attribute.
    If you want to bind the value with the backing bean, use the 'value' attribute and a proper object type to store the value in. E.g. String or any Number. If you want to use a specific object type, then you have to create/supply/specify a converter for that.
    So you have 3 options:
    1) replace value="#{myBean.inputText1}" by binding="#{myBean.inputText1}"
    or
    2) replace HtmlInputText type by String type (for example).
    or
    3) supply a converter which converts between HtmlInputText and String (fairly meaningless option indeed, but it works)

  • Somebody help: JSF validation issue

    Hi,
    It's my first project using JSF. There is a jsp listing customer info with an h:dataTable component, and at the top of the page there is a form with several fields such as name, age and so on therefore the user can add a new customer. The user can edit an existing customer in that form as well, by selecting one of the rows of the dataTable.
    The name field is constrained by a required="true" attribute. The problem I encounted was: I clicked the "Add" button with the name field(<h:inputText id="name">) keeping blank, validation failed, and that's what I expected. Then I selected a customer from the dataTable, but the customer info did not appear at the upper form fields, though it seems that a customer had been selected to be updated.
    Below are the code snippets of the jsp & backing bean(I'm sorry for the formatting):
    <f:view>
           <h:form>
                  <h:inputHidden value="#{custBean.editing}"/>
                 <h:inputHidden value="#{custBean.selectedId}"/>
                <h:outputLabel for="name" value="Name:"/>
                <h:inputText id="name" value="#{custBean.name}" required="true"/>
               <h:message for="name"/>
               <h:commandButton rendered="#{custBean.editing}" value="Update" action="#{custBean.update}"/>
              <h:commandButton rendered="#{custBean.editing}" value="Cancel" action="#{custBean.cancel}"/>
             <h:commandButton rendered="#{not custBean.editing}" value= "Add" action= "#{custBean.add}"/>
        <h:form>
        <h:form>
             <h:dataTable value="#{csutBean.custModel}" var="cust">
                   <h:column>
                            <f:facet name="header">
                                   <h:outputText value="Name"/>
                            </f:facet>
                        <h:outputText value="#{cust.name}"/>
                  </h:column>
                  <h:column>
                          <h:commandButton value="Edit" action="#{custBean.selectForUpdate}" immediate="true"/>
                   </h:column>
              </h:dataTable>
        </h:form>
    </f:view>
    // CustomersBean.java
    // imports...
    public class CustomersBean extends Object{
            private int selectedId;
            private String name;
            private DataModel custModel;
            public int getSelectedId()
                   return selectedId;
            public void setSelectedId(int id)
                  selectedId= id;
             public boolean isEditing()
                    return editing;
             public void setEditing(boolean editing)
                    this.editing= editing;
              public void DataModel getCustModel()
                      if(null== custModel)
                              custModel= new ListDataModel();
                      List<Customer> cl= SomeOtherBean.getCustomers();
                      custModel.setWrappedData(cl);
                      return custModel;
              public void add()
                     Customer cust= new Customer();
                    cust.setName(name);
                     SomeOtherBean.add(cust);
                   cancel();
             public void update()
                    Customer cust= new Customer();
                    cust.setId(selectedId);
                    cust.setName(name);
                     SomeOtherBean.update(cust);
                     cancel();
              public void selectForUpdate()
                      selectedId= ((Customer)custModel.getRowData).getId();
                       editing= true;
              public void cancel()
                        editing= false;
                       name="";
    }

    I did not express the issue clearly. It would work well if I revoke the "required" atribute from the "name" inputText. Validation is the root cause I think.
    I do have a POJO named Customer to hold the row data, and it could be called a DTO right? The editing property is just a flag indicating user action status. And the selectedId property may be delegated from the id property of the Customer POJO.
    Thanks for the interesting article anyway.

  • JSF Validation failure causes entered values to be lost

    I've created a JSP that has required="true" and a requiredMessage on several elements.
    If any one element on the page fails it's validation on submit(ie was left blank), when the screen is redrawn all the entered values have disappeared.
    This is obviously not going to be acceptable to a user as there may have been 5 valid entries and one mistake, and they now have to retype every entry.
    Can anyone suggest why the form might be being cleared like this?

    I'm using reference implementation 1.2 04-b10
    I've tried using an implementation of validator and it makes no difference.
    It's the only example of an inline validator other than required, which seems to work ok.
    I've got around the problem for now by doing the validation in the method called when the user hits submit. It's not quite right as if the 'required' validation fails they get mutliple messages showing these failures, but the codeRef validation doesn't even fire until all the other validation passes.

  • Dynamic values for JSF selectOneMenu using javascrpt. JSF validation error.

    Hi,
    Im using Myfaces 1.2 (tomahawk) . I have a very bulky page having lot of drop down menus. It has a datatable containing four drop downs in a row and the datatable has close to 40 rows (with pagination) . Each of the drop downs have close to 100 items . This makes the page size very huge and not suitable for an internet application.
    Im thinking of a way to have the drop downs populated using javascript in body onload event so that the page size reduces drastically. I have defined a selectOneMenu without selectItems. So before page load there will be no items in the drop down. The body onLoad method populates the drop downs and the page gets rendered as expected. All the javascript events related to these drop downs works fine. When page is submitted i want the selected value in the bean variable.
    But when the page gets submitted im getting the error
    Validation Error: Value is not valid
    Can someone let me know the reason behind this and a way to solve this problem . Its really URGENT...
    Please help....
    Thanks,
    Swami.

    JSFdeveloper wrote:
    Validation Error: Value is not valid During validations phase, the submitted value of UISelectOne/UISelectMany will be tested against the current SelectItems. If it is not covered by the SelectItems, you will get this error.
    Its really URGENT...This is your own problem, not our problem. This way you're only trying to move the problem/pressure to us and pushing us to respond soon. This is considered very rude in terms of netiquette. Next time you do so, I have no problem adding you to my ignore list. [Just ask questions the smart way|http://catb.org/esr/faqs/smart-questions.html].

Maybe you are looking for

  • A way to track where all the Sub Var are applied?

    Hopefully this is the section where to post. Is there a way of tracking where all the substitution variables are being used in the reports? Either in reports or calc scripts, or in a 3rd format, if there is one. We just don't want to open up each scr

  • The Administrator has made a change

    Hi! We are running Exchange 2013 together with Outlook 2013. After installing Exchange SP1, the following messages appears on all clients: "The Exchange admin has made a change that requires you to restart Oulook" This appears when starting Outlook,

  • Cannot turn up or down the speaker by the volume key

    I try to use the volume key to adjust the volume, but not working

  • Inspection Lot For Calibration Order

    Dear All, I want to create a Calibation Order for equipment. I have craeted a general task list, assign master inspection charaterstic in the operation using the control key QM01. Now I am assigning this task list directly to the order and releasing

  • Best Approach to distribute business app

    I have created a new software product called Care Control.  It is a large system that works inside UK Care Homes.   The system uses lots of different technology, but fundamentally I am using a SQL Server Database and an IIS Server to host an interfac