开发者

Problem with Java Faces and h:selectOneMenu

I have a Modal form with three combos:

<h:panelGrid columns="3" id="parameterLabels" >
    <h:outputText id="lblCdrType" styleClass="formLabel" value="#{BRulesConfig.lblParameter307}:" />
    <h:selectOneMenu id="cmdCdrType" style="font-family:Verdana, Arial, Helvetica, sans-serif ;font-size: 14px; width:240px ;"
                     value="#{BRulesConfig.cdrType}" >
        <f:selectItem itemValue="-1" itemLabel="-Select One-" itemDisabled="true"/>
        <f:selectItems id="lstCdrType" value="#{BRulesConfig.cdrTypeList}" />
        <a4j:support event="onchange" action="#{BRulesConfig.changeStatus}"
                     reRender="parameterValuesPanelTypeModule,parameterValuesPanelFields,pnlValuesPar,formMessage,formErrMessage,formErrorNew,formInfoNew"
                     ajaxSingle="开发者_运维百科true" status="idLoading" />
    </h:selectOneMenu>
</h:panelGrid>

<h:panelGrid columns="2" id="parameterValuesPanelTypeModule"  >
    <h:outputText id="lblCdrTypeModule" styleClass="formLabel" value="#{BRulesConfig.lblParameter307_output}:" />
    <h:selectOneMenu id="cmdCdrTypeModule" style="font-family:Verdana, Arial, Helvetica, sans-serif ;font-size: 14px; width:240px ;"
                     value="#{BRulesConfig.parameterValueBean.id_output}"  >
        <f:selectItem itemValue="-1" itemLabel="-Select One-" itemDisabled="true"/>
        <f:selectItems id="lstCdrTypeModule" value="#{BRulesConfig.cdrTypeModules}" />
        <a4j:support event="onchange" ajaxSingle="true" status="idLoading" />
    </h:selectOneMenu>
</h:panelGrid>

<h:panelGrid columns="2" id="parameterValuesPanelFields"  >
    <h:outputText id="lblCdrTypeModuleField" styleClass="formLabel" value="#{BRulesConfig.lblParameter307_field}: #{BRulesConfig.parameterValueBean.value}" />
    <h:selectOneMenu id="cmdCdrTypeModuleField" style="font-family:Verdana, Arial, Helvetica, sans-serif ;font-size: 14px; width:240px ;"
                     value="#{BRulesConfig.parameterValueBean.value}">
        <f:selectItem itemValue="-1" itemLabel="-Select One-" itemDisabled="true"/>
        <f:selectItems id="lstCdrTypeModuleField" value="#{BRulesConfig.cdrTypeModulesField}" />
    </h:selectOneMenu>                                                                          
</h:panelGrid>

Everything is fine and is loading perfectly.

The first combo cmdCdrType uses ajax to load the second combox cmdCdrTypeModule. It does so using the onchange event (a4j:support). This is also true for the third combobox: cmdCdrTypeModule.

I don't have any problem using any of these combos. But when I try to save all the info that I have stored, I receive the following error message sent by Faces:

28-jul-2011 18:04:51 com.sun.faces.lifecycle.RenderResponsePhase execute
INFO: WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
sourceId=frm307:cmdCdrTypeModuleField[severity=(ERROR 2), summary=(frm307:cmdCdrTypeModuleField: Error de Validación: Valor no es correcto.), detail=(frm307:cmdCdrTypeModuleField: Error de Validación: Valor no es correcto.)]

Translating the last line:

Error de Validacion :Valor no es Correcto 
Validation Error: Value is not valid

I tried using a converter class, but the same error is displayed. I tried changing my beans setters but nothing changes. My faces config looks like this:

<managed-bean>
    <managed-bean-name>BRulesConfig</managed-bean-name>
    <managed-bean-class>com.tsb.mediation.brules.configuration.BRulesConfigurationControl</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
</managed-bean>

I don't know why I'm receiving this error. Any help is appreciated.


Validation Error : Value is not correct -- is not a converter error but validator error. Do you use custom objects in the drop down? If yes, then you need to overwrite equals() and hashCode() on the custom object.


During the apply request values phase of the form submit request, JSF will re-obtain the list of select items from the bean to compare the selected value against the list in order to prevent the server side against spoofed/tampered submits. If no one of the items equals() the selected value, then you will get this error.

It look like that the bean is request scoped and/or that you're doing business in the getter. You need to put the bean in the view scope (or when you're using JSF 1.x, the <a4j:keepAlive> on the bean) and move all business logic outside the getters to get it to work properly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜