tags:

views:

829

answers:

1

I have table with two SelectOneMenu in row. I need populate data in second menu depending on the data that was selected in first. I need bypass validation phase because. I add rows to table dynamically.

+-- Table ---------------------------------------------------+
|                           |                                |
| Field 1: |____________|v| |  Field 2.1: |____________|v|   |
+---------------------------+--------------------------------+
| Field 1: |____________|v| |  Field 2.2: |____________|v|   |
|                           |                                |
+------------------------------------------------------------+

There is my code:

                    <h:selectOneMenu value="#{rowItem.selectedItem1}"  immediate="true" valueChangeListener="#{rowItem.processValueChange}"
                                     onchange="submit()">
                        <f:selectItems value="#{rowItem.selectItems1}" />
                    </h:selectOneMenu>
                </h:column>
                <h:column>
                    <h:selectOneMenu value="#{rowItem.selectedItem1}" >
                        <f:selectItems value="#{rowItem.seriesItems2}" />
                    </h:selectOneMenu>

               ..... some more elements
            </h:dataTable>

In my table backing bean i have

 private ArrayList<RowItem> rowItems;

I want to use processValueChange() in my class that represent RowItem but i can't, becouse i can't bind SelectOneMenu in my RowItem class.

+1  A: 

Why have all of that logic in the rowItem bean?

Are you able to use the Richfaces framework?

If you, then you would be able to do something roughly like this:

<h:selectOneMenu value="#{rowItem.selectedItem1}">
  <f:selectItems value="#{rowItem.selectItems1}" />
  <a4j:support event="onchange" ajaxSingle="true" action="#{helperBean.loadSeriesItems2}" reRender="areaToRender"/>
</h:selectOneMenu>
Damo
Thank, I think it's time for using richfaces now :). May be you can recommend some easy tutorial for beginning.
masterzim
I can recommend the book "Practical Richfaces". Really good! Otherwise you end up googling answers like crazy.
Thank that is a good book. There are very many examples, it's a really good.
masterzim