You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by HENRY Pierre <pi...@unine.ch> on 2007/05/10 15:56:01 UTC

selectOneMenu inside of dataTable

Hi,

I have a use case where I need to delete some "Location" objets.
"Events" objects are bound to these locations (parent-child, where the
location is the parent).

So when I try to delete a location that has children, I display a
dataTable of all the events children. In each line of the dataTable, I
have a combo (selectOneMenu) with the different possible actions :
delete the children, or bind it to another "Location", so all the other
locations are in the combo box. When I submit the form, I check what is
the action and process all the events accordingly. If the value is
"delete" I delete the event, if the value is "dummy" I don't do
anything, and if the value is an id, I move the event to the location
matching the id.

The list of events, is a List property of the "locationForm" session
managed bean :#{locationForms.events}.

The selectItems list for the other locations is a property ot the
"locationForm" too.

The value of the selectOneMenu is a String property of the Event class
(I know, Event is a model class and shouldn't contain any UI stuff, but
right now I just need it to work).

Here is what the jsp look like : 

<h:form>
...
<t:dataTable var="event" value="#{locationForm.events}"
rowClasses="standardTable_Row1,standardTable_Row2">
<h:column >
<h:outputText value="#{event.beginDate}" />
</h:column>
<h:column>
<h:outputText value="#{event.eventType}" />
</h:column>
<h:column>
<h:outputText value="#{event.titleAbbreviated}"/>
</h:column>
<h:column>

<h:selectOneMenu styleClass="actionSelectInput"
value="#{event.actionOnChild}" >

 <f:selectItem itemLabel="choose an action..." itemValue="dummy"/>
 <f:selectItem itemLabel="------------------------" itemValue="dummy"/>
 <f:selectItem itemLabel="Delete" itemValue="delete" />
 <f:selectItem itemLabel="------------------------" itemValue="dummy"/>
 <f:selectItem itemLabel="Move to :" itemValue="dummy"/>
 <f:selectItem itemLabel=" " itemValue="dummy"/>
 <f:selectItems value="#{locationForm.moveChildrenItems}"/>


</h:selectOneMenu>

</h:column>
</t:dataTable>

...

<h:commandButton
action="#{locationForm.processChildren}"
immediate="true"
value="#{bundle.action_ok}"
styleClass="inputText">
</h:commandButton>
... 
</h:form>

The page renders fine, with the selects and everything. But when I
submit the form, the values of each event's "actionOnChild" property are
not updated. The setActionOnChil method is not called once on any of the
events.

The processChildren method is executed, but all the "actionOnChild"
values are null;

So am I missing something ? Isn't the value of actionOnChild of each
event in the list supposed to be updated on submit ? If so, please show
me how I can retreive the values of the selectOneMenus.

Let me know if you need more details, snippets of code or whatever.

Thanks,

Pierre


RE: selectOneMenu inside of dataTable

Posted by William Diaz Pabón <wi...@hotmail.com>.
it uses:


- implements ActionListener
- public void processAction(ActionEvent anEvent) throws 
AbortProcessingException


Cordialmente.

William Diaz Pabón
Tunja - Boyacá - Colombia





>From: "HENRY Pierre" <pi...@unine.ch>
>Reply-To: "MyFaces Discussion" <us...@myfaces.apache.org>
>To: "MyFaces Discussion" <us...@myfaces.apache.org>
>Subject: RE: selectOneMenu inside of dataTable
>Date: Fri, 11 May 2007 09:05:30 +0200
>
>Somebody, please ?
>
>-----Message d'origine-----
>De : HENRY Pierre [mailto:pierre.henry@unine.ch]
>Envoyé : jeudi, 10. mai 2007 15:56
>À : users@myfaces.apache.org
>Objet : selectOneMenu inside of dataTable
>
>Hi,
>
>I have a use case where I need to delete some "Location" objets.
>"Events" objects are bound to these locations (parent-child, where the 
>location is the parent).
>
>So when I try to delete a location that has children, I display a dataTable 
>of all the events children. In each line of the dataTable, I have a combo 
>(selectOneMenu) with the different possible actions :
>delete the children, or bind it to another "Location", so all the other 
>locations are in the combo box. When I submit the form, I check what is the 
>action and process all the events accordingly. If the value is "delete" I 
>delete the event, if the value is "dummy" I don't do anything, and if the 
>value is an id, I move the event to the location matching the id.
>
>The list of events, is a List property of the "locationForm" session 
>managed bean :#{locationForms.events}.
>
>The selectItems list for the other locations is a property ot the 
>"locationForm" too.
>
>The value of the selectOneMenu is a String property of the Event class (I 
>know, Event is a model class and shouldn't contain any UI stuff, but right 
>now I just need it to work).
>
>Here is what the jsp look like :
>
><h:form>
>...
><t:dataTable var="event" value="#{locationForm.events}"
>rowClasses="standardTable_Row1,standardTable_Row2">
><h:column >
><h:outputText value="#{event.beginDate}" /> </h:column> <h:column> 
><h:outputText value="#{event.eventType}" /> </h:column> <h:column> 
><h:outputText value="#{event.titleAbbreviated}"/>
></h:column>
><h:column>
>
><h:selectOneMenu styleClass="actionSelectInput"
>value="#{event.actionOnChild}" >
>
>  <f:selectItem itemLabel="choose an action..." itemValue="dummy"/>  
><f:selectItem itemLabel="------------------------" itemValue="dummy"/>  
><f:selectItem itemLabel="Delete" itemValue="delete" />  <f:selectItem 
>itemLabel="------------------------" itemValue="dummy"/>  <f:selectItem 
>itemLabel="Move to :" itemValue="dummy"/>  <f:selectItem itemLabel=" " 
>itemValue="dummy"/>  <f:selectItems 
>value="#{locationForm.moveChildrenItems}"/>
>
>
></h:selectOneMenu>
>
></h:column>
></t:dataTable>
>
>...
>
><h:commandButton
>action="#{locationForm.processChildren}"
>immediate="true"
>value="#{bundle.action_ok}"
>styleClass="inputText">
></h:commandButton>
>...
></h:form>
>
>The page renders fine, with the selects and everything. But when I submit 
>the form, the values of each event's "actionOnChild" property are not 
>updated. The setActionOnChil method is not called once on any of the 
>events.
>
>The processChildren method is executed, but all the "actionOnChild"
>values are null;
>
>So am I missing something ? Isn't the value of actionOnChild of each event 
>in the list supposed to be updated on submit ? If so, please show me how I 
>can retreive the values of the selectOneMenus.
>
>Let me know if you need more details, snippets of code or whatever.
>
>Thanks,
>
>Pierre
>

_________________________________________________________________
Las mejores tiendas, los precios mas bajos, entregas en todo el mundo, 
YupiMSN Compras: http://latam.msn.com/compras/


RE: selectOneMenu inside of dataTable

Posted by HENRY Pierre <pi...@unine.ch>.
Somebody, please ? 

-----Message d'origine-----
De : HENRY Pierre [mailto:pierre.henry@unine.ch] 
Envoyé : jeudi, 10. mai 2007 15:56
À : users@myfaces.apache.org
Objet : selectOneMenu inside of dataTable

Hi,

I have a use case where I need to delete some "Location" objets.
"Events" objects are bound to these locations (parent-child, where the location is the parent).

So when I try to delete a location that has children, I display a dataTable of all the events children. In each line of the dataTable, I have a combo (selectOneMenu) with the different possible actions :
delete the children, or bind it to another "Location", so all the other locations are in the combo box. When I submit the form, I check what is the action and process all the events accordingly. If the value is "delete" I delete the event, if the value is "dummy" I don't do anything, and if the value is an id, I move the event to the location matching the id.

The list of events, is a List property of the "locationForm" session managed bean :#{locationForms.events}.

The selectItems list for the other locations is a property ot the "locationForm" too.

The value of the selectOneMenu is a String property of the Event class (I know, Event is a model class and shouldn't contain any UI stuff, but right now I just need it to work).

Here is what the jsp look like : 

<h:form>
...
<t:dataTable var="event" value="#{locationForm.events}"
rowClasses="standardTable_Row1,standardTable_Row2">
<h:column >
<h:outputText value="#{event.beginDate}" /> </h:column> <h:column> <h:outputText value="#{event.eventType}" /> </h:column> <h:column> <h:outputText value="#{event.titleAbbreviated}"/>
</h:column>
<h:column>

<h:selectOneMenu styleClass="actionSelectInput"
value="#{event.actionOnChild}" >

 <f:selectItem itemLabel="choose an action..." itemValue="dummy"/>  <f:selectItem itemLabel="------------------------" itemValue="dummy"/>  <f:selectItem itemLabel="Delete" itemValue="delete" />  <f:selectItem itemLabel="------------------------" itemValue="dummy"/>  <f:selectItem itemLabel="Move to :" itemValue="dummy"/>  <f:selectItem itemLabel=" " itemValue="dummy"/>  <f:selectItems value="#{locationForm.moveChildrenItems}"/>


</h:selectOneMenu>

</h:column>
</t:dataTable>

...

<h:commandButton
action="#{locationForm.processChildren}"
immediate="true"
value="#{bundle.action_ok}"
styleClass="inputText">
</h:commandButton>
... 
</h:form>

The page renders fine, with the selects and everything. But when I submit the form, the values of each event's "actionOnChild" property are not updated. The setActionOnChil method is not called once on any of the events.

The processChildren method is executed, but all the "actionOnChild"
values are null;

So am I missing something ? Isn't the value of actionOnChild of each event in the list supposed to be updated on submit ? If so, please show me how I can retreive the values of the selectOneMenus.

Let me know if you need more details, snippets of code or whatever.

Thanks,

Pierre