Using Collection to accept values of JSF form

I want to accept all values of a JSF form in a List. There might be varius tags such as inputText, selectOneMenu, inputTextArea etc. tags in the form. But my aim is to accept it to List of bean not to individual bean property for each tag. I can't decide how'll I write the List in bean so that it works as I want. I know that Java generic can be used but I don't know about it yet. Could anyone help me do this....either the way to accept values in List or in Java generic?

Thanks

[497 byte] By [islandhopea] at [2007-11-27 8:44:15]
# 1
Why do you want to do this? From my point of view, you'd better have a really good reason because you are going to do a lot of work circumventing the built-in JSF handling and the built-in handling seems much more useful.
RaymondDeCampoa at 2007-7-12 20:44:57 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Thanks....actually I've to do this because I'm not sure how many tags will be there during runtime as all these are in a datatable and appear based on values retrieved from database. I think it won't be clear to you before you see the code. The datatable code is as follows:

<t:dataTable styleClass="standardTable" headerClass="standardTable_Header" footerClass="standardTable_Header" rowClasses="standardTable_Row1,standardTable_Row2" columnClasses="standardTable_Column,standardTable_ColumnCentered,standardTable_Column" id="data" var="rmqc" value="#{rawmaterialqcdetails.allRMQCDetailByID}" preserveDataModel="true">

<h:column>

<f:facet name="header">

<h:outputText value="Test"/>

</f:facet>

<h:inputTextarea value="#{rmqc.test}" rows="6" cols="35" readonly="true"> </h:inputTextarea>

</h:column>

<h:column>

<f:facet name="header">

<h:outputText value="Specification"/>

</f:facet>

<h:inputTextarea value="#{rmqc.specification}" rows="6" cols="35" readonly="true"> </h:inputTextarea>

</h:column>

<h:column>

<f:facet name="header">

<h:outputText value="Result"/>

</f:facet>

<f:subview id="resultc" rendered="#{rmqc.result=='c'}">

<h:selectOneMenu id="comply" styleClass="selectOneMenu" value="#{rawmaterialqcdetails.testValueC}">

<f:selectItem itemLabel="" itemValue=""/>

<f:selectItem itemLabel="Complies" itemValue="Complies"/>

<f:selectItem itemLabel="Does not comply" itemValue="Does not comply"/>

</h:selectOneMenu>

<h:outputText value="Sampling Quantity:">

</h:outputText>

<h:inputText id="samplingQuantity" value="#{rawmaterialqcdetails.samplingQuantityC}" styleClass="textbox"></h:inputText>

<h:commandLink action="#{rawmaterialqcdetails.addTestValueC}">

<h:outputText value="Ok"/>

<f:param name="ID" value="#{rmqc.ID}"/>

<f:param name="RMID" value="#{rmqc.RMID}"/>

</h:commandLink>

</f:subview>

<f:subview id="resulti" rendered="#{rmqc.result=='i'}">

<h:inputText id="input" size="20" styleClass="textbox" value="#{rawmaterialqcdetails.testValueI}"/>

<h:outputText value="Sampling Quantity:">

</h:outputText>

<h:inputText id="samplingQuantity" value="#{rawmaterialqcdetails.samplingQuantityI}" styleClass="textbox"></h:inputText>

<h:commandLink action="#{rawmaterialqcdetails.addTestValueI}">

<h:outputText value="Ok"/>

<f:param name="ID" value="#{rmqc.ID}"/>

<f:param name="RMID" value="#{rmqc.RMID}"/>

</h:commandLink>

</f:subview>

</h:column>

</t:dataTable>

Look in the selectOneMenu tag with id=="comply" value is taken in rawmaterialqcdetails.testValueC bean property. This selectOnemenu tag may appear more than once on the form based on value from database which is decided in subview with id="resultc". Please note that in the subview rendered portion where I check rmqc.result=='c'. Now the selectOneMenu tag may appear several times based on rendering rmqc.result=='c'. But the value of this selectOneMenu tag is always taken in a single bean property rawmaterialqcdetails.testValueC.

This way there's an inputText tag with id samplingQuantity whose value is taken in rawmaterialqcdetails.samplingQuantityC bean property. The scenario is the same as selectOneMenu tag for this. When I click on the commandLink the action rawmaterialqcdetails.addTestValueC saves value to database. Now the problem is when these selectOneMenu and inputText tags appear more than once on form, the values are not accepted in rawmaterialqcdetails.testValueC and

rawmaterialqcdetails.samplingQuantityC bean properties and I can't send these to database.

There's one more subview with id="resulti" where the case is the same. This is why I want to collect all values accepted from form to List and then send all those to database. Do you have any idea how can I get around this?

Thanks

islandhopea at 2007-7-12 20:44:58 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

As an aside, perhaps you can edit the post where you added all the code and make this thread legible again.

The dataTable component has facilities to help you accomplish what you need here. It adds things to the components so that it can tell which row each one belongs to. I haven't actually tried to use the functionality where you can have input components that update your model, but according to my documentation no additional effort is required.

RaymondDeCampoa at 2007-7-12 20:44:58 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

Thanks..I think I need more help from you. Could you provide the documentation you mentioned about or if possible one example? There were no problems if I could know how many rows will be there. But it's based on value from database..so I can't take bean properties. I just had a single bean property and accepting value in it based on rendered "c" or "i". Now when values are accepted more than once in a single bean property it doesn't get saved to database. Please help get around this

Thanks

islandhopea at 2007-7-12 20:44:58 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
Three things:1) See this thread: http://forum.java.sun.com/thread.jspa?threadID=5188643&tstart=02) Google for BalusC's page on dataTables3) If you want the documentation I am referring to, buy JavaServer Faces: The Complete Reference by Schalk and Burns.
RaymondDeCampoa at 2007-7-12 20:44:58 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...