Problem with custim IDs in within dataTable /S subTable
nille Jun 23, 2009 5:40 AMHi,
as stated in the subject, I have a problem with custom IDs in a subTable.
The (sub)table contains 19 rows and 7 column and therefore 133 field. Each field is represented by an object in a 2-dimensional array kept in the backing bean. The subTable 'value' keeps the rows (and iterates through them) and and 'rich:columns' gets the the appropriate (1-dimensional) array of fields from the mentioned 2-dimensional array and displays the information stored within each object of the array. Each object has a property 'identifier' which should be used for the 'id' attribute of eg 'h:outputText' and contains just the prefix'id_' followed by the index of the field starting at '0' to '132'.
<h:form id="monatsberichtUnfaelleForm"> .... <rich:dataTable value="#{monatsberichtReportAction_Tarifbereiche.listWithNumberOfSubtables}" var="listHeaders" id="Monatsbericht_Tarifbereiche_MainTable"> ... <rich:subTable value="#{monatsberichtReportAction_Tarifbereiche.getReportTable().descriptions}" var="tarifbereicheTableRow" border="0" id="monatsberichtValuesSubTable"> <rich:column styleClass="#{tarifbereicheTableRow.styleClass}"> <h:outputLink value="#{tarifbereicheTableRow.linkTarget}"> <h:outputText value="#{tarifbereicheTableRow.linkName}"/> </h:outputLink> </rich:column> <rich:column styleClass="#{tarifbereicheTableRow.styleClass}"> <h:outputText value="#{tarifbereicheTableRow.description}"/> </rich:column> <rich:columns value="#{monatsberichtReportAction_Tarifbereiche.getReportTable().getArrayWithFieldValues(tarifbereicheTableRow.mappedToValuesRowId)}" var="field" border="0" index ="ind3" styleClass="#{field.getStyleClass()}" colspan="#{field.getColspan()}" visible="#{!field.isHidden()}"> <h:inputText value="#{field.fieldIntegerValue}" id="#{field.identifier}_test"> <a4j:support event="onchange" ajaxSingle="false" action="#{monatsberichtReportAction_Tarifbereiche.calculateSums(0, tarifbereicheTableRow.mappedToValuesRowId, ind3)}" reRender="id_6, id_126"/> </h:inputText> <h:outputText value="#{field.identifier}"/> <h:outputText value="#{field.fieldIntegerValue}" id="#{field.identifier}" /> </rich:columns> </rich:subTable>
If I display the 'identifier' property in a 'h:outputText' element the correct value is displayed, see above or:
<h:outputText value="#{field.identifier}"/>
If I use this values in the 'id' attribute, each row contains IDs from 'id_0' to 'id_6' with some prefix generated by the IDs of the parent elements. The have the following pattern:
<input id="monatsberichtUnfaelleForm:Monatsbericht_Tarifbereiche_MainTable:monatsberichtValuesSubTable:0:id_0_test"... <span id="monatsberichtUnfaelleForm:Monatsbericht_Tarifbereiche_MainTable:monatsberichtValuesSubTable:0:id_0"... .. <input id="monatsberichtUnfaelleForm:Monatsbericht_Tarifbereiche_MainTable:monatsberichtValuesSubTable:0:id_1_test"... <span id="monatsberichtUnfaelleForm:Monatsbericht_Tarifbereiche_MainTable:monatsberichtValuesSubTable:0:id_1"... .. <input id="monatsberichtUnfaelleForm:Monatsbericht_Tarifbereiche_MainTable:monatsberichtValuesSubTable:0:id_2_test"... <span id="monatsberichtUnfaelleForm:Monatsbericht_Tarifbereiche_MainTable:monatsberichtValuesSubTable:0:id_2"... ... <input id="monatsberichtUnfaelleForm:Monatsbericht_Tarifbereiche_MainTable:monatsberichtValuesSubTable:18:id_0_test"... <span id="monatsberichtUnfaelleForm:Monatsbericht_Tarifbereiche_MainTable:monatsberichtValuesSubTable:18:id_0"... .. <input id="monatsberichtUnfaelleForm:Monatsbericht_Tarifbereiche_MainTable:monatsberichtValuesSubTable:18:id_1_test"... <span id="monatsberichtUnfaelleForm:Monatsbericht_Tarifbereiche_MainTable:monatsberichtValuesSubTable:18:id_1"... ... <input id="monatsberichtUnfaelleForm:Monatsbericht_Tarifbereiche_MainTable:monatsberichtValuesSubTable:18:id_2_test"... <span id="monatsberichtUnfaelleForm:Monatsbericht_Tarifbereiche_MainTable:monatsberichtValuesSubTable:18:id_2"... ...
The reason I need 'my unique' IDs is that I need to update some fields (h:outptText elements) of the table via AJAX. Updating the whole table works fine but takes far too long.
Maybe...very likely I`m doing something wrong...
Note: I used #{field.identifier} both for a h:inputText and h:outputText. To avoid 'duplicateId' error messages a Concatenated '_test' to the 'id' attribute of the h:inputText.
Thanks a lot in advance,
Kind Regards,
nille