0

Being a newbie at JSF, I've ran into a situation that I don't understand how to solve. I have a page with 2 selectOneMenu objects (financialColumn, linesOfBusiness) depending on the values of 2 other selectOneMenu objects (year, businessType). The contents of financialColumn & linesOfBusiness can be completely different depending on year or businessType selected (all components are RequestScoped beans).

<h:outputText value="Data Year:" />
<h:selectOneMenu id="year" value="#{YearOptions.year}" >
    <f:selectItems value="#{YearOptions.options}" />
    <f:ajax execute="@this businesstype" render="financialColumn linesOfBusiness" />
</h:selectOneMenu>

<h:outputText value="Business Type:" />
<h:selectOneMenu id="businesstype" value="#{BusTypeOptions.busListKey}" > 
    <f:selectItems value="#{BusTypeOptions.options}" />
    <f:ajax execute="@this year" render="financialColumn linesOfBusiness" />
</h:selectOneMenu>

<h:outputText value="Select Financial Amount to Report on:" />
<h:selectOneMenu id="financialColumn" value="#{FinColumn.finColumn}">
    <f:selectItems value="#{FinColumn.options}"/>
</h:selectOneMenu>

<h:outputText value="Select Lines of Business to include:" />
<h:selectManyListbox id="linesOfBusiness" value="#{LobOptions.linenums}" size="5" >
    <f:selectItems value="#{LobOptions.options}"/>
</h:selectManyListbox>
:
:
<h:commandButton value="Submit" type="submit" action="/pages/report/lines-of-business-summary" 

The issue I'm trying to figure out is as long as I don't change or go back to the original values of financialColumn & linesOfBusiness my report page displays but when I change businessType value which causes complete change in financialColumn & linesOfBusiness values then I receive "•criteria:financialColumn: Validation Error: Value is not valid". Why is this happening and how can I fix it?

Thanks

  • possible duplicate of [Validation Error: Value is not valid](http://stackoverflow.com/questions/9069379/validation-error-value-is-not-valid) - point 2 of accepted answer over there clearly applies to you as you're using a request scoped bean – BalusC May 08 '13 at 14:53
  • @BalusC - Thank you sir. I reviewed point 2 as suggested but the same list can't be preserved since (in my case) the business types have completely different finaicialColumn & linesOfBusiness lists. Now what? – sTemple May 08 '13 at 16:04
  • Just fix your model in such way that you never perform business logic in a getter method and that the bean's state is properly maintained during (post)construction, if necessary based on request parameters or other managed beans. – BalusC May 08 '13 at 16:10
  • @BalusC - again many thanks. All business logic in Post Construction init(), also using ManagedProperty to pass year & businessType values to beans; still getting validation error. If I change businessType bean to session scoped all is well. Very confusing. – sTemple May 08 '13 at 18:14
  • Try to print each values of FinColumn.options and also the value which you are trying to set at the time you are setting BusTypeOptions.busListKey. – Jitesh May 08 '13 at 19:59

0 Answers0