You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Aaron Bartell <aa...@gmail.com> on 2005/03/04 06:28:46 UTC

selectOneMenu and dataTable - need each row returned.

I am loading a dataTable with multiple drop downs. Traditionally I would 
use a data table to allow the user to do an action against one of the 
rows, but in this case I allow them to pick something in each row that I 
would like to have returned to me.  My problem is I can't seem to figure 
out how to get the data back into my program.  I always get the last 
drop down's value in my backing bean property 'temp' (which makes sense 
given that it is the last loaded and I don't have any action buttons or 
command links on each row).

I was hoping I could somehow have the list of selected values put into a 
backing bean that has a String[].


<x:dataTable id="data" var="setting" value="#{PrinterCtl.settingList}" 
rows="10">
      <h:column>
        <f:facet name="header">
              <h:outputText   value="" styleClass="header"/>
           </f:facet>
           <h:outputText value="#{setting.name}" styleClass="copy"/>   
      </h:column>                               
      <h:column>
        <f:facet name="header">
              <h:outputText   value="" styleClass="header"/>
           </f:facet>
        <h:selectOneMenu id="options_id" value="#{PrinterCtl.temp}">
              <f:selectItems value="#{setting.option}" />
        </h:selectOneMenu>   
      
</h:column>                                                             
</x:dataTable>   


Thoughts?
Aaron Bartell

Re: selectOneMenu and dataTable - need each row returned.

Posted by Aaron Bartell <aa...@gmail.com>.
That did it Heath!  Thanks for the idea.  I didn't realize this, but if 
I create a setting for the property specified in the value= attribute on 
dataTable that it will 'set' the Collection when the request comes back 
in. I guess I should have expected that being how I get all my other 
fields data. This model rocks!! 

Thanks, Aaron Bartell


<x:dataTable id="data"
        var="setting"
        value="#{*PrinterCtl.psList*}"
        rows="10"
        >
    <h:column>
        <f:facet name="header">
            <h:outputText   value="" styleClass="header"/>
        </f:facet>
        <h:outputText value="#{setting.name}" styleClass="copy"/>   
    </h:column>                               
    <h:column>
        <f:facet name="header">
            <h:outputText   value="" styleClass="header"/>
        </f:facet>
        <h:selectOneMenu id="options_id" value="*#{setting.selecteduid}*">
            <f:selectItems value="#{setting.optionList}" />
        </h:selectOneMenu>   
    </h:column>                                                          
   
</x:dataTable>





Heath Borders wrote:

>You should hook your menu's "value" attribute to your "setting" bean
>and not to the bean containing the "settingList".
>
>
>On Thu, 03 Mar 2005 23:28:46 -0600, Aaron Bartell
><aa...@gmail.com> wrote:
>  
>
>>I am loading a dataTable with multiple drop downs. Traditionally I would
>>use a data table to allow the user to do an action against one of the
>>rows, but in this case I allow them to pick something in each row that I
>>would like to have returned to me.  My problem is I can't seem to figure
>>out how to get the data back into my program.  I always get the last
>>drop down's value in my backing bean property 'temp' (which makes sense
>>given that it is the last loaded and I don't have any action buttons or
>>command links on each row).
>>
>>I was hoping I could somehow have the list of selected values put into a
>>backing bean that has a String[].
>>
>><x:dataTable id="data" var="setting" value="#{PrinterCtl.settingList}"
>>rows="10">
>>     <h:column>
>>       <f:facet name="header">
>>             <h:outputText   value="" styleClass="header"/>
>>          </f:facet>
>>          <h:outputText value="#{setting.name}" styleClass="copy"/>
>>     </h:column>
>>     <h:column>
>>       <f:facet name="header">
>>             <h:outputText   value="" styleClass="header"/>
>>          </f:facet>
>>       <h:selectOneMenu id="options_id" value="#{PrinterCtl.temp}">
>>             <f:selectItems value="#{setting.option}" />
>>       </h:selectOneMenu>
>>
>></h:column>
>></x:dataTable>
>>
>>Thoughts?
>>Aaron Bartell
>>
>>    
>>
>
>
>  
>

Re: selectOneMenu and dataTable - need each row returned.

Posted by Heath Borders <he...@gmail.com>.
You should hook your menu's "value" attribute to your "setting" bean
and not to the bean containing the "settingList".


On Thu, 03 Mar 2005 23:28:46 -0600, Aaron Bartell
<aa...@gmail.com> wrote:
> I am loading a dataTable with multiple drop downs. Traditionally I would
> use a data table to allow the user to do an action against one of the
> rows, but in this case I allow them to pick something in each row that I
> would like to have returned to me.  My problem is I can't seem to figure
> out how to get the data back into my program.  I always get the last
> drop down's value in my backing bean property 'temp' (which makes sense
> given that it is the last loaded and I don't have any action buttons or
> command links on each row).
> 
> I was hoping I could somehow have the list of selected values put into a
> backing bean that has a String[].
> 
> <x:dataTable id="data" var="setting" value="#{PrinterCtl.settingList}"
> rows="10">
>      <h:column>
>        <f:facet name="header">
>              <h:outputText   value="" styleClass="header"/>
>           </f:facet>
>           <h:outputText value="#{setting.name}" styleClass="copy"/>
>      </h:column>
>      <h:column>
>        <f:facet name="header">
>              <h:outputText   value="" styleClass="header"/>
>           </f:facet>
>        <h:selectOneMenu id="options_id" value="#{PrinterCtl.temp}">
>              <f:selectItems value="#{setting.option}" />
>        </h:selectOneMenu>
> 
> </h:column>
> </x:dataTable>
> 
> Thoughts?
> Aaron Bartell
> 


-- 
-Heath Borders-Wing
hborders@mail.win.org