Validation error in JSF

Hi,
In my sample project the UI is powered by JSF, overall application architecture is J2EE.
In a scenario,we have a page where we toggle between radio buttons and page reloads everytime we toggle, with different forms.
In specific we have three radion buttons namely x ,y and z.
When the default page loads, x is selected and when i shift my selection to y the page reloads with different forms and no error is seen.
Next when i select z page reloads with different forms but error is displayed on the top of the page as below
"Validation error:Value is not valid."
Once the error is dispalyed on the page the error continues to remain eventhough we revert back the radio selection.
In the above case jsp calls the js and the snippet of the same is as below
JSP snippet:
<TD><h:selectOneRadio styleClass="selectOneRadio" id="radio1"
value="#{sessionScope.sameJam}"
onclick=return jump_onclick(this,event);>
<f:select itemValue="x"
itemLabel="#{labels.label_x}" />
<f:select itemValue="y"
itemLabel="#{labels.label_y}" />
<f:select itemValue="z"
itemLabel="#{labels.label_z}" />
</h:selectOneRadio></TD>
JS snippet:
function jump_onclick(thisObj,thisEvent){
thisObj.form.submit();
Java code:
protected HtmlSelectOneRadio getRadio1() {
if (radio1 == null) {
radio1 = (HtmlSelectOneRadio) findComponentInRoot("radio1");
return radio1;
Thanks in advance.

Re-wrote the below code in jsp
<h:form rendered="#{sS.selectedItem =='x'}" styleClass="selectOneRadio" >
<h:selectOneRadio rendered="#{sS.selectedItem =='x'}" >
<f:selectItem itemValue="x" itemLabel="labelx" />
<f:selectItem itemValue="y" itemLabel="labely" />
<f:selectItem itemValue="z" itemLabel="labelz"/>
</h:selectOneRadio>
</h:form>
<h:form rendered="#{sS.selectedItem =='y'}" styleClass="selectOneRadio" >
<h:selectOneRadio rendered="#{sS.selectedItem =='y'}" >
<f:selectItem itemValue="x" itemLabel="labelx" />
<f:selectItem itemValue="y" itemLabel="labely" />
<f:selectItem itemValue="z" itemLabel="labelz"/>
</h:selectOneRadio>
</h:form>
<h:form rendered="#{sS.selectedItem =='z'}" styleClass="selectOneRadio" >
<h:selectOneRadio rendered="#{sS.selectedItem =='z'}" >
<f:selectItem itemValue="x" itemLabel="labelx" />
<f:selectItem itemValue="y" itemLabel="labely" />
<f:selectItem itemValue="z" itemLabel="labelz"/>
</h:selectOneRadio>
<h:commandButton value="submit" action="#{sS.action}" />
</h:form>Below is my java code in SS class:
package mypackage;
public class SS {
    private String selectedItem;
public SS(){
String selectedItem = "x";
    public void action() {
        System.out.println("Selected item: " + selectedItem);
    public String getSelectedItem() {
        return selectedItem;
    public void setSelectedItem(String selectedItem) {
        this.selectedItem = selectedItem;
}Result is:
Instead of getting 3 radio buttons, i get a submit button my page.
Please correct me if I am wrong somewhere.

Similar Messages

  • Validation error message in JSF 1.2

    I am testing my Web application inside Tomcat 6.0.2 and using JSF 1.2. I was surprised to see that validation error messages do not only display the custom error message, but also the id tag and a "Validation Error: " text. For instance, if an input text component has the required property set to true and the user does not fill in value, the following error message will be displayed on page submiision: "hello:test: Validation Error: Value is required." instead of just "Value is required.". I am wondering if there is a way to silence the id tag and the "Validation Error: " text. hello:test id tag reflects the fact that the form has an id of "hello" and the input text component an id equal to "test".

    Hello
    I'm quite new to this technology. Would like to know how can we replace the 'annoying component id' with label while generationg validation/conversion error message.
    E.g:
    'for:compID' some error message
    must be formated as
    'compLabel' some error message
    I happened to know that this feature is supported in JSF 1.2 impl. But didn't work for me with Sun RI.Can any body give me some sample code snippet for the same
    Thanks
    Jobinesh

  • JSF, NetBeans and customizing of Standard Validation Errors

    Hello together,
    i want to use german Standard Validation Errors via a own .properties File:
    1.
    Here is my faces-config.xml ( the entries are uncommented ! ):
    <faces-config>
    <application>
    <locale-config>
    <default-locale>de</default-locale>
    <supported-locale>de</supported-locale>
    <supported-locale>en</supported-locale>
    </locale-config>
    *<message-bundle>alles.mymessages</message-bundle>*
    </application>
    </faces-config>
    2.
    Here is mymessages.properties-File in package alles:
    javax.faces.validator.NOT_IN_RANGE=Das angegebene Attribut liegt nicht zwischen den erwarteten Werten {0} und {1}.
    javax.faces.validator.NOT_IN_RANGE_detail="{2}"\:Eingegebener Wert liegt nicht im erwarteten Bereich von {0} bis {1}.
    javax.faces.validator.LongRangeValidator.LIMIT=Validierungsfehler
    javax.faces.validator.LongRangeValidator.LIMIT_detail=Eingegebener Wert kann nicht in den korrekten Typ umgewandelt werden.
    javax.faces.validator.LongRangeValidator.MAXIMUM=Validierungsfehler
    javax.faces.validator.LongRangeValidator.MAXIMUM_detail="{1}"\:Wert ist gr\u00F6\u00DFer als das erlaubte Maximum"{0}".
    3.
    Here the part of the JSF-View with the Validator:
    <ui:textField binding="#{WorkTypeEdit.textFieldBeschartKzSoll}" converter="#{WorkTypeEdit.bigIntegerConverter1}"
    id="textFieldBeschartKzSoll" required="true" style="height: 24px; width: 48px" validator="#{WorkTypeEdit.longRangeValidator1.validate}"/>
    The application still shows the standard englisch validation error text. What is wrong here ?
    I' am using NetBeans 5.5.1 with VWP and the deploment is to Glassfish server.
    Thanks a lot.
    HJA

    Hello Raymond,
    i did some coding and create additional a custom validator:
    My JSF-View part:
    <ui:textField binding="#{WorkTypeEdit.textFieldBeschartKzSoll}" converter="#{WorkTypeEdit.integerConverter1}"
    id="textFieldBeschartKzSoll" maxLength="2" required="true" style="height: 24px; width: 48px" *validator="#{MyValidation.validateInput}">*
    *<f:validateLongRange minimum="1" maximum="9"></f:validateLongRange>*
    </ui:textField>
    My custom validator in Myvalidation class:
    public void validateInput (FacesContext facescontext, UIComponent component, Object value) throws ValidatorException
    long min = 0, max = 0;
    Locale locale = facescontext.getViewRoot ().getLocale ();
    String mb = facescontext.getApplication ().getMessageBundle ();
    ResourceBundle rb = ResourceBundle.getBundle (mb, locale);
    Validator[] validator = ((UIInput) component).getValidators ();
    for (int i=0; i < validator.length; i++)
    if (validator[i] instanceof LongRangeValidator)
    LongRangeValidator lv = (LongRangeValidator) validator;
    long lvalue = Long.valueOf ((String)value.toString ());
    min = lv.getMinimum ();
    max = lv.getMaximum ();
    if (lvalue < min || lvalue > max)
    ((UIInput) component).setValid (false);
    *String message = rb.getString ("javax.faces.validator.NOT_IN_RANGE");*
    *String messageDetail = rb.getString ("javax.faces.validator.NOT_IN_RANGE_detail");*
    *facescontext.addMessage (component.getClientId (facescontext), new FacesMessage (FacesMessage.SEVERITY_ERROR,message,messageDetail));* }
    What happen now is, at first i get the german message because of rb.getString........ so the locale is working
    and then the englisch message follows in the message component.
    Sorry that i take your time so long...
    HJA

  • JSF select one menu keeps giving me summary=Validation Error: Value is not

    Hi all,
    I'm using five select menus in a JSP file.
    the other four are populated whenever the first menu changes its value (ValueChange event).
    after the menus are populated, i select a item in each menu and submit it.
    but when i submit the form i get the following error:
    E com.sun.faces.context.FacesContextImpl addMessage Adding Message[sourceId=form2:menu61,summary=Validation Error: Value is not valid)
    [12/1/06 11:25:58:541 EST] 00000030 jsf           E com.sun.faces.context.FacesContextImpl addMessage Adding Message[sourceId=form2:menu5,summary=Validation Error: Value is not valid)
    [12/1/06 11:25:58:557 EST] 00000030 jsf           E com.sun.faces.context.FacesContextImpl addMessage Adding Message[sourceId=form2:menu6,summary=Validation Error: Value is not valid)where menu61, menu5, menu6 are the menus on the form.
    someone pls throw some light on this.
    -Seshu

    Hi,
    Since you are using a request scoped bean things work like this:
    1. You fetch your list, for example from a database, with a bean that is put in request scope.
    2. You populate your select component on the jsp page.
    3. You select an item in the select component and submits the form.
    4. When the form is submitted the selected value has to be validated against the list it was chosen from. Since you retrieved the list from a bean in request scope the list isn't available when you submit the form and the getter for the list probably returns an empty list which gives you the validation error.
    What you have to do is to get the list the item was selected from when submitting the form. This can be done in different ways. Either you keep your list in the session between the requests or you get the list from your data storage again. This is a horrible "feature" with JSF and from what I know it's impossible to turn this validation off.
    /klejs

  • 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].

  • Validation error while trying to change a value in a request scope bean

    - JBoss 4.2.3.GA
    - JSF 1.2_09-b01-BETA1 (Mojarra)
    - Java 5 Update 17
    Hello, everybody!
    I'm having the following problem in my JSF web application:
    I have a request scope backing bean. The first time this bean is loaded (I check
    this with the ResponseStateManager.isPostBack() method) I fill a list of SelectItem
    instances that are to be displayed in the JSF page in a +<h:selectOneMenu>+ component.
    The list goes, of course, to the +<h:selectOneMenu>+'s +<f:selectItems>+ facet child
    component. In the constructor I also define the value that goes to the value property
    of the +<h:selectOneMenu>+ component. This value is a property in the backing bean, as
    is the list of SelectItem instances. Until now we have something like this:
    The backing bean declaration in faces-config.xml:
    <managed-bean>
        <managed-bean-name>solicitacaoGeral</managed-bean-name>
        <managed-bean-class>br.urca.solicitacoes.web.PaginaSolicitacaoGeral</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    The relevant parts of the JSF page:
    <h:form id="form">
        <h:selectOneMenu value="#{solicitacaoGeral.setorOrigem}" id="foco">
            <f:selectItems value="#{solicitacaoGeral.setoresOrigem}" />
        </h:selectOneMenu>
    </h:form>
    The relevant parts of the backing bean class:
    public class PaginaSolicitacaoGeral
        private final List<SelectItem> fSetoresOrigem = new ArrayList<SelectItem>();
        private Setor fSetorOrigem;
        public PaginaSolicitacaoGeral()
            if (primeiraExibicao()) // First load (!ResponseStateManager.isPostBack())
                // Fill fSetoresOrigem...
                fSetorOrigem = ...
            else // Page submitted
                // Read below...
        public List<SelectItem> getSetoresOrigem()
            return fSetoresOrigem;
        public Setor getSetorOrigem()
            return fSetorOrigem;
        public void setSetorOrigem(Setor setorOrigem)
            fSetorOrigem = setorOrigem;
        private boolean primeiraExibicao()
            String idFerramentaExibicao =
                FacesContext.getCurrentInstance().getViewRoot().getRenderKitId();
            ResponseStateManager gerenciadorEstadoResposta =
                RenderKitUtils.getResponseStateManager(
                FacesContext.getCurrentInstance(), idFerramentaExibicao);
            return !gerenciadorEstadoResposta.isPostback(
                FacesContext.getCurrentInstance());
    }But when the user submits the form and the bean constructor is called again
    (this time the method ResponseStateManager.isPostBack() returns true ),
    in the else block in the constructor above, I need to fill fSetoresOrigem with
    other values and also the fSetorOrigem field because, of course, the fSetorOrigem
    field has to be a valid value that exists in the new fSetoresOrigem list.
    JSF is not complaining about the change to the list items, but it is complaining
    to the change to the fSetorOrigem field (the list value), even though it is a
    valid value present in the list. So I'm getting this error message:
    08:23:54,312 INFO  [lifecycle] WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
    sourceId=form:foco[severity=(ERROR 2), summary=(form:foco: Validation Error: Value is not valid), detail=(form:foco: Validation Error: Value is not valid)]I suppose that JSF is comparing the new value of the field fSetorOrigem with the value
    it has in the view state. As the value is different it is raising the error. That's
    what I suppose. But am I not able the change the value in the postback? I've already
    checked and the value is valid. It corresponds to a value that exists in the list.
    I really need a solution to this problem as I'm stuck with this and can't proceed until
    I find a solution to this. What I am doing wrong and how can I solve this?
    Thank you very much.
    Marcos

    BalusC wrote:
    It is comparing the selected value against the List<SelectItem> returned by getSetoresOrigem() as it is during the apply request values phase of the form submit request.Ok. That's what I supposed JSF was doing.
    BalusC wrote:
    If the selected value isn't in there, then you will get this error.I can understand this, but is this right? As I said, the old value isn't really there because I changed the list values to new ones. But the new value (the value of fSetorOrigem ) corresponds to a value that exist in the new list items, so a valid value. So JSF is not considering that I also changed the list, not just the value. It is comparing the new value with the old list, not the new one. Acting like this JSF is making the page looks like a static HTML page, not a dynamic one. If I can't change the list and the value, what's the point of that? In my point of view I'm not doing anything wrong, I'm not violating any JSF rules.
    Marcos

  • Validation error corrupts component tree?

    I've got a strange problem trying to use validation on input fields.
    The basic setup is as follows:
    I've got a page divided into two parts with separate h:form tags, the one holding a dataTable with some elements and the other showing the element details in inputFields once an item is selected in the dataTable via a commandLink. A commandButton on the detail side allows you to update the values of the selected item which is being reflected in the dataTable on reload. So far so good.
    Here comes the strange part:
    All the inputFields are marked required. Now once you leave a field empty and try to submit the form, you get a validation error as expected. BUT if you now select a different element from the dataTable, ONLY the field whose validation formerly failed is being updated, the other fields still show the same value as before. The backing bean method that belongs to the commandLink is being executed, and the underlying data object of the input fields is being set properly, only the values in the component tree aren't updated. This behaviour persists until you enter a valid value in the formerly invalid input field and submit. Debugging shows that as long as at least one field has had validation errors, only the getter of these backing beans properties are being invoked during render response phase, as opposed to the "normal" case where the getters of all the backing beans properties are being called.
    For some reason, the render response phase seems to ignore the other components in the component tree when there was some validation error on one or more fields.
    Another interesting observation:
    This is the behaviour if I don't specify an action attribute in the commandLink selecting an element from the dataTable, as I want to return to the same page again. But if I define a navigation case that brings me to the same page and put that into the action attribute, the problem doesn't occur. Unfortunately this is no option for me, as I'm aiming to do all this with ajax.
    I've created a simple example so you can try out yourself:
    test.jsp:
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <html>
    <head>
    <title>validator test</title>
    </head>
    <body>
    <f:view>
         <h:form id="form1">
              <h:dataTable id="table" value="#{bean.datas}" var="data" binding="#{bean.table}" border="1">
                   <h:column>
                        <h:commandLink actionListener="#{bean.selectData}" value="#{data.string1}" />
                   </h:column>
                   <h:column>
                        <h:outputText value="#{data.string2}" />
                   </h:column>
              </h:dataTable>
              </h:form>
         <hr />
         <h:form id="form2">
              <h:inputText value="#{bean.data.string1}" id="field1" required="true" />
              <h:inputText value="#{bean.data.string2}" id="field2" required="true"/>
              <h:commandButton value="submit" />
         </h:form>
    </f:view>
    </body>
    </html>Bean.java:
    needs to be defined in faces-config.xml as bean "bean" with session scope
    import java.util.ArrayList;
    import java.util.List;
    import javax.faces.component.html.HtmlDataTable;
    import javax.faces.event.ActionEvent;
    public class Bean {
         private Data data;
         private List<Data> datas;
         private HtmlDataTable table;
         public Bean() {
              datas = new ArrayList<Data>();
              datas.add(new Data("data1value1","data1value2"));
              datas.add(new Data("data2value1",""));
         public void selectData(ActionEvent event) {
              data = (Data)table.getRowData();
         public List<Data> getDatas() {
              return datas;
         public Data getData() {
              return data;
         public void setData(Data data) {
              this.data = data;
         public HtmlDataTable getTable() {
              return table;
         public void setTable(HtmlDataTable table) {
              this.table = table;
         public class Data {
              private String string1;
              private String string2;
              public Data(String string1, String string2) {
                   this.string1 = string1;
                   this.string2 = string2;
              public String getString1() {
                   return string1;
              public void setString1(String value) {
                   string1 = value;
              public String getString2() {
                   return string2;
              public void setString2(String value) {
                   string2 = value;
    }My system setup:
    WinXP Professional
    JDK 1.6.0-b105
    Tomcat 5.5.20 (also tried 6.0.7)
    JSF RI 1.1.02_b08 (also tried 1.2_04-b10-p01, different but anyway not expected behaviour with MyFaces 1.1.5)
    Thanks for any input,
    Harry.

    Is there noone here who can tell me if this is behavior like specified or if I miss some point?
    A possible solution seems to be telling JSF programmatically to rebuild the view root. Does anyone if this is possible?

  • Validation messages in JSF (when not using ADF faces)

    I've spent some time with JDeveloper 11 and would like to use it on an upcoming project. I have to target IE 6, so I won't be able to take advantage of ADF Faces. Instead I'd like to use the ADF Business Components with a standard JSF interface so it can be used by people still running IE 6.
    I've created a Business Component from a database table and can bind a JSF HTML Creation Form by dragging the appropriate view from the AppModule in the Data Controls pane. However, when I attempt to submit the page without all the fields being valid I get the following validation error message:
    j_id__ctru2:j_id__ctru6: Validation Error: Value is required. j_id__ctru2:j_id__ctru6: Validation Error: Value is required.
    I've tried making this more descriptive, but editing the error message in the Validation Rules section of the Business Component has no effect. What's the best way to convey a meaningful validation message to the user when not using ADF Faces?
    Also - I'm still very new to JDeveloper. Since I won't be able to rely on my users having Internet Explorer 7, would you recommend I stay with JDeveloper 10? The examples and documentation I've seen so far for JDeveloper 11 appear heavily biased towards using ADF Faces so I'm starting to wonder how much support is there for using plain old JSF.
    Thanks for your time!

    Hi,
    if you are completely new to this then I suggest to use JDeveloper 10.1.3 and ADF Faces in there. Its good to use with IE6 as well. Currently we do have more tutorials available for this release than for 11, which for this reason is a better choice for someone new to this
    Frank

  • LOV selection fails when there are validation errors on the base page

    Hi
    I have lovs and some other required fields on a page . If there are any validation error on one of those text fields and if I open the LOV (not related to the text fields) and tries to select
    an item from the LOV search results, it doesn't do it until unless I go back to the base page and correct all the validation errors on the text fields eventhough those text fields have nothing to do with the LOV.
    Any suggestion is appreciated.
    Thanks
    Anwar

    I am on Anwar's team, and I've been dealing with the same problem, although on a different page.
    The JSPX for a contrived example is below. I can provide backing bean code, if needed.
    The form contains two LOVs. Both fields are required. If you leave both fields blank and click Continue, you get a red box around both fields and error messages are displayed. If you then click the magnifying glass to select from the first LOV, the LOV pop-up is rendered. However, you cannot make a selection, either by double-clicking a line item or by clicking OK (the OK button has no effect). All you can do is cancel.
    Interestingly, the act of clicking the magnifying glass on the first LOV gets rid of the red box around that field. So, once you cancel out, the second LOV actually does work. If there were more than two fields on the page, that wouldn't happen. The problem seems to be that the LOV doesn't work unless there are no validation errors on the page other than for the LOV which is being invoked.
    As you can see, immediate="true" is set on both LOVs. The behavior is the same whether this is true or not.
    I'm left thinking there must be something obvious that we're missing... but none of us can see it.
    Thanks,
    KEN
    <?xml version='1.0' encoding='windows-1252'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
              xmlns:f="http://java.sun.com/jsf/core"
              xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
      <jsp:directive.page contentType="text/html;charset=windows-1252"/>
      <f:view>
        <af:document title="Add Item">
          <af:form>
            <af:panelGroupLayout>
                <af:panelHeader text="Header">
                    <af:panelFormLayout>
                        <af:inputListOfValues label="Id" searchDesc="Search" popupTitle="Supplier Id"
                                              simple="true" required="true" id="supplierId"
                                              model="#{viewScope.AddItemBackingBean.supplierIdListOfValuesModel}"
                                              value="#{viewScope.AddItemValuesBean.supplier.id}"
                                              autoSubmit="true" immediate="true"/>
                        <af:inputListOfValues label="Description" searchDesc="Search" popupTitle="Supplier Id"
                                              simple="true" required="true" id="supplierDescription"
                                              model="#{viewScope.AddItemBackingBean.supplierDescriptionListOfValuesModel}"
                                              value="#{viewScope.AddItemValuesBean.supplier.description}"
                                              autoSubmit="true" immediate="true"/>
                        <f:facet name="footer">
                            <af:panelGroupLayout layout="horizontal" halign="right" >
                              <af:commandButton text="Continue"
                                                actionListener="#{viewScope.AddItemBackingBean.continueAction}"
                                                id="continueButton" />
                            </af:panelGroupLayout>
                        </f:facet>
                    </af:panelFormLayout>
                </af:panelHeader>
            </af:panelGroupLayout>
          </af:form>
        </af:document>
      </f:view>
    </jsp:root>

  • Validation Errors on TabPanel - How do I show them to user?

    I have a tabbed panel on one of my JSF pages with required=true validation on field on tabs other than the first tab. When the user does not fill in those required fields on tabs other than the first one, those field level error messages are not shown because the screen renders showing the first tab. Is there a way to switch the focus to whatever tab has validation errors, so the user can see that they missed filling in information? Right now, they just get a screen flicker and don't know what happened.
    Thanks,
    MIke BRubaker

    It plays fine on a computer,
    Are you saying the burned disk plays fine on your computer?
    Happy Holidays

  • How to deal with validation errors from DAO layer.

    I have been pondering on how to deal with validation errors from DAO layer.
    Lets say you have a DAO that can save a car object. A car has a year, make, model, vin and so on. During the save operation of this DAO, it validates the car attributes to see if they pass some business rules. If it does not it throws some validation exception that contains all the validation errors. These validation errors know nothing about jsf or my components it just knows what attributes on the object are invalid and why.
    If I just want to show those errors at the top of the page that would be no problem I could just create some FacesMessage objects and add them to the FacesContext messages. But if the DAO layer is telling me that the make attribute is invalid it would be nice to map it to the make field on the screen. I am wondering if any of you have tackled this problem or have some ideas on how to tackle it?
    Brian

    Let it throw an exception with a self explaining message, then catch it and embed that message in a FacesMessage.
    Or let it throw more specific exception types (InvalidCarMakeException extends CarDAOException and so on) and let JSF handle it with own FacesMessage message.

  • Validation error when using a cutsomer converter

    Hey i'm trying to use a customer converter to convert between an object and a string, i can get it to display but when i submit my form i get the error Validation Error: Value is not valid.
    Here is my jsp code
    <h:selectManyCheckbox value="#{AddModuleBean.selectedSchemes}" converter="schemeConverter" id="scheme" >
    <f:selectItems value="#{AddModuleBean.schemeList}" id="schemeList" />
    </h:selectManyCheckbox>

    Maybe you just did something incredibly wrong. If I copy my "Objects in selectOneMenu" example and make small changes to your needs accordingly (Foo --> Scheme, selectOneMenu --> selectManyCheckbox and Foo selectedItem --> List<Scheme> selectedItems), then it just works flawlessly.
    Here it is:
    JSF<%@taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
    <%@taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <f:view>
        <html>
            <head><title>Test</title></head>
            <body>
            <h:form>
                <h:selectManyCheckbox value="#{myBean.selectedItems}">
                    <f:selectItems value="#{myBean.selectItems}" />
                    <f:converter converterId="schemeConverter" />
                </h:selectManyCheckbox>
                <h:commandButton value="Submit" action="#{myBean.action}" />
                <h:messages />
            </h:form>
        </body>
        </html>
    </f:view>MyBeanpackage mypackage;
    import java.util.ArrayList;
    import java.util.List;
    import javax.faces.model.SelectItem;
    public class MyBean {
        // Init ---------------------------------------------------------------------------------------
        private static SchemeDAO schemeDAO = new SchemeDAO();
        private List<SelectItem> selectItems;
        private List<Scheme> selectedItems;
            fillSelectItems();
        // Actions ------------------------------------------------------------------------------------
        public void action() {
            System.out.println("Selected Scheme items: " + selectedItems);
        // Getters ------------------------------------------------------------------------------------
        public List<SelectItem> getSelectItems() {
            return selectItems;
        public List<Scheme> getSelectedItems() {
            return selectedItems;
        // Setters ------------------------------------------------------------------------------------
        public void setSelectedItems(List<Scheme> selectedItems) {
            this.selectedItems = selectedItems;
        // Helpers ------------------------------------------------------------------------------------
        private void fillSelectItems() {
            selectItems = new ArrayList<SelectItem>();
            for (Scheme scheme : schemeDAO.list()) {
                selectItems.add(new SelectItem(scheme, scheme.getName()));
    }Schemepackage mypackage;
    public class Scheme {
        // Init ---------------------------------------------------------------------------------------
        private String name;
        // Constructors -------------------------------------------------------------------------------
        public Scheme() {
            // Default constructor, keep alive.
        public Scheme(String name) {
            this.name = name;
        // Getters ------------------------------------------------------------------------------------
        public String getName() {
            return name;
        // Setters ------------------------------------------------------------------------------------
        public void setName(String name) {
            this.name = name;
        // Helpers ------------------------------------------------------------------------------------
        public String toString() {
            // Override Object#toString() so that it returns a human readable String representation.
            // It is not required by the Converter or so, it just pleases the reading in the logs.
            return "Scheme[" + name + "]";
    }SchemeDAOpackage mypackage;
    import java.util.ArrayList;
    import java.util.LinkedHashMap;
    import java.util.List;
    import java.util.Map;
    public class SchemeDAO {
        // Init ---------------------------------------------------------------------------------------
        private static Map<String, Scheme> schemeMap;
        static {
            loadSchemeMap(); // Preload the fake database.
        // Actions ------------------------------------------------------------------------------------
        public Scheme load(String name) {
            return schemeMap.get(name);
        public List<Scheme> list() {
            return new ArrayList<Scheme>(schemeMap.values());
        public Map<String, Scheme> map() {
            return schemeMap;
        // Helpers ------------------------------------------------------------------------------------
        private static void loadSchemeMap() {
            // This is just a fake database. We're using LinkedHashMap as it maintains the ordering.
            schemeMap = new LinkedHashMap<String, Scheme>();
            schemeMap.put("schemeName1", new Scheme("schemeName1"));
            schemeMap.put("schemeName2", new Scheme("schemeName2"));
            schemeMap.put("schemeName3", new Scheme("schemeName3"));
    }SchemeConverterpackage mypackage;
    import javax.faces.component.UIComponent;
    import javax.faces.context.FacesContext;
    import javax.faces.convert.Converter;
    public class SchemeConverter implements Converter {
        // Init ---------------------------------------------------------------------------------------
        private static SchemeDAO schemeDAO = new SchemeDAO();
        // Actions ------------------------------------------------------------------------------------
        public Object getAsObject(FacesContext context, UIComponent component, String value) {
            // Convert the unique String representation of Scheme to the actual Scheme object.
            return schemeDAO.load(value);
        public String getAsString(FacesContext context, UIComponent component, Object value) {
            // Convert the Scheme object to its unique String representation.
            return ((Scheme) value).getName();
    }faces-config.xml<?xml version="1.0" encoding="UTF-8"?>
    <faces-config xmlns="http://java.sun.com/xml/ns/javaee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
        version="1.2">
        <converter>
            <converter-id>schemeConverter</converter-id>
            <converter-class>mypackage.SchemeConverter</converter-class>
        </converter>
        <managed-bean>
            <managed-bean-name>myBean</managed-bean-name>
            <managed-bean-class>mypackage.MyBean</managed-bean-class>
            <managed-bean-scope>request</managed-bean-scope>
        </managed-bean>
    </faces-config>

  • Validation Error after updating a SelectOneMenu via Ajax (DWR)

    I have a <t:selectOneMenu> that is bound to a backing bean together with a <f:selectItems> that is bound to a SelectItems[] attribute in the same backing bean. See below:
    <t:selectOneMenu forceId="true"
    id="department"
    value="#{DeptBean.departmentId}">
    <f:selectItems value="#{DeptBean.departmentList}" />
    </t:selectOneMenu>
    When the user changes another field on my page, I use DWR to retrieve a new list of departments and update the <t:selectOneMenu> accordingly. That works just fine.
    The problem is that if I select a value from the updated department list and then submit the page I get a "Validation Error".
    I suspect that the JSF Component Tree still has the old list of values and does some validation which obviously fails.
    Has anyone dealt with this before? Any ideas would be appreciated!

    <t:selectOneMenu forceId="true"
    id="department"
    value="#{DeptBean.departmentId}">
    <f:selectItems value="#{DeptBean.departmentList}"
    />
    </t:selectOneMenu>What is the type of departmentId ? If it is not a String, then try making it a String and see if the issue is resolved. I am not sure if this will help you. But its worth a try.

  • How to render validation error messages with a specified language.

    in my jsf project, i want to display validation error messages in Turkish. But due to the performance considerations we keep our servers language setting in English.
    how can we manage..i will be very appreciated with your guiding.
    note: we have already tried the solutions with defining our local and supported local language on faces-config.xml . it did not work.

    there is only one difference. my development environments(my local server) local setting is Turkish. but the Application servers local settings is EnglishSounds like you defined application supported locales but no application default locale.
    If there is no match of requested locale and supported locale, application default locale will be used.
    If application default is also not available JVM default locale will be used.
    This would explain the differences.
    (Mojarra)

  • Validation error removes all url parameters

    The url of my jsf page has some url parameters. Using the JSF 2.0 build-in PRG pattern support and outcome with viewId and parameters it's easy to work with url parameters now.
    My problem is when some server-side validation error is occurred JSF navigates back on the same view Id but removes all my url parameters.
    Is there any way to resolve this issue to remain page bookmarkable even after some validation error is happened?

    Thank you for advice.
    Issue was added:.
    [https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1653|https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1653]

Maybe you are looking for

  • Background processing in Flex

    I have two questions here. But, I guess they both are related 1. I have a calendar application, where I display set of events based on time for a day. I need to start a background process to check if any of the events are scheduled for the next half

  • Skype 7.1 crashing with APPCRASH

    the Skype 7.0 related discussion[This discussion was split from the Skype 7.0 related discussion as it's now about Skype 7.1] I have the same problem. and the link for previous build is not correct.

  • Deleted sys.android.bar accidentally while side-loading android apps

    I deleted sys.android.bar accidentally while side-loading android apps. How can I get it back? Is there a way to get the bar file and reload it? I did try the older version that is floating around and it does not work. I looked at the directions for

  • HT4848 Error creating recovery disk in Disk Assist

    I've carefully followed all instruction in this post: http://support.apple.com/kb/ht4848, but I am having an error when creating the recovery disk. The recovery Disk Assist starts creating it, but stops early on. The message I get is titled "Conclusi

  • Automatic calling of procedure

    Is there any way in Oracle 8i where I can call a procedure or a script (.sql) automatically during a particular time daily. Thanks!!!