Simon Kitching wrote:

Hansjörg Meuschel wrote:

Simon Kitching wrote:

Hansjörg Meuschel wrote:

Hi,
the problem is the surrounding t:datatable: Children of this component all get the same id as the component does not create new objects for each iteration.



That's just not true.

Both the h:dataTable and t:dataTable components use the "flyweight" pattern to avoid creating a component-per-row. However they ensure that the id effectively varies per row for the component, making this transparent for most purposes.


oh ok... i don't know exactly all implementation details, however what i know is that the t:datatable has some serious problems:

Example:
<h:form>
<t:datatable>
<t:column>
<h:inputText>
</ ...>

THIS WILL NOT WORK! (all input field get the same id)


<h:form>
<h:datatable>
<h:column>
<h:inputText>
</ ...>
THIS WILL WORK! (all input field get different ids)

This is the reason why the t:datatable can't be used with submittable componenents! Or am I doing something very wrong here ??


You're doing something very wrong, though I don't know what. Input fields in tables work fine for me, in MyFaces 1.1.1 and SVN head (I haven't tried older versions).

Note that the *id* of the component stays the same, but the *clientId* changes. Given
 <h:form id="form1">
  <h:dataTable id="table1">
   <h:column>
    <h:inputText id="input1">

During rendering, the *same* input-text component is called once per row. If it calls getId(), it sees "input1". However if it calls "getClientId", it sees:
  form1:table1:0:input1
  form1:table1:1:input1
  form1:table1:2:input1
which are all unique ids.

Same process occurs during decoding of submitted values, so each submitted value gets processed correctly.

I also had a collapsible panel within a table and had that working a few months ago. I've deleted that code since, though, as I've taken a different approach to presenting that data.

Note that there have been some problems reported recently regarding tomahawk on sun's JSF RI implementation which *might* be related. I've only tried this on the MyFaces JSF implementation.

Regards,

Simon



Hello Simon,
thanks for your explanations.

i've tried your example:

the output using

<h:form id="form1">
<h:dataTable id="table1" value="#{projectBenefitBean.allTargetValues}" var="targetperiod">
  <h:column>
   <h:inputText id="input1"/>
  </h:column>
 </h:dataTable>
</h:form>

<form id="HJMEU:form1" name="HJMEU:form1" method="post" action="/Sophi2/pdca/plan/target0.faces" 
enctype="application/x-www-form-urlencoded"><table id="HJMEU:form1:table1">
<tbody>
<tr>
<td><input id="HJMEU:form1:table1:0:input1" name="HJMEU:form1:table1:0:input1" type="text" 
value="" /></td>
</tr>
<tr>
<td><input id="HJMEU:form1:table1:1:input1" name="HJMEU:form1:table1:1:input1" type="text" 
value="" /></td>

</tr>
<tr>
<td><input id="HJMEU:form1:table1:2:input1" name="HJMEU:form1:table1:2:input1" type="text" 
value="" /></td>
</tr>
<tr>
<td><input id="HJMEU:form1:table1:3:input1" name="HJMEU:form1:table1:3:input1" type="text" 
value="" /></td>
</tr>
<tr>
<td><input id="HJMEU:form1:table1:4:input1" name="HJMEU:form1:table1:4:input1" type="text" 
value="" /></td>
</tr>
<tr>
<td><input id="HJMEU:form1:table1:5:input1" name="HJMEU:form1:table1:5:input1" type="text" 
value="" /></td>
</tr>
<tr>
<td><input id="HJMEU:form1:table1:6:input1" name="HJMEU:form1:table1:6:input1" type="text" 
value="" /></td>
</tr>
<tr>

<td><input id="HJMEU:form1:table1:7:input1" name="HJMEU:form1:table1:7:input1" type="text" 
value="" /></td>
</tr>
<tr>
<td><input id="HJMEU:form1:table1:8:input1" name="HJMEU:form1:table1:8:input1" type="text" 
value="" /></td>
</tr>
<tr>
<td><input id="HJMEU:form1:table1:9:input1" name="HJMEU:form1:table1:9:input1" type="text" 
value="" /></td>
</tr>
<tr>
<td><input id="HJMEU:form1:table1:10:input1" name="HJMEU:form1:table1:10:input1" type="text" 
value="" /></td>
</tr>
</tbody>
</table>

-> just as you said: different client ids for each iteration are generated

and now the output using
<h:form id="form1">
<t:dataTable id="table1" value="#{projectBenefitBean.allTargetValues}" var="targetperiod">
  <h:column>
   <h:inputText id="input1"/>
  </h:column>
 </t:dataTable>
</h:form>

<table id="HJMEU:form1:table1">
<tbody id="HJMEU:form1:table1:tbody_element">
<tr><td><input id="HJMEU:form1:table1:input1" name="HJMEU:form1:table1:input1" type="text" 
value="" /></td></tr>
<tr><td><input id="HJMEU:form1:table1:input1" name="HJMEU:form1:table1:input1" type="text" 
value="" /></td></tr>
<tr><td><input id="HJMEU:form1:table1:input1" name="HJMEU:form1:table1:input1" type="text" 
value="" /></td></tr>
<tr><td><input id="HJMEU:form1:table1:input1" name="HJMEU:form1:table1:input1" type="text" 
value="" /></td></tr>

<tr><td><input id="HJMEU:form1:table1:input1" name="HJMEU:form1:table1:input1" type="text" 
value="" /></td></tr>
<tr><td><input id="HJMEU:form1:table1:input1" name="HJMEU:form1:table1:input1" type="text" 
value="" /></td></tr>
<tr><td><input id="HJMEU:form1:table1:input1" name="HJMEU:form1:table1:input1" type="text" 
value="" /></td></tr>
<tr><td><input id="HJMEU:form1:table1:input1" name="HJMEU:form1:table1:input1" type="text" 
value="" /></td></tr>
<tr><td><input id="HJMEU:form1:table1:input1" name="HJMEU:form1:table1:input1" type="text" 
value="" /></td></tr>
<tr><td><input id="HJMEU:form1:table1:input1" name="HJMEU:form1:table1:input1" type="text" 
value="" /></td></tr>
<tr><td><input id="HJMEU:form1:table1:input1" name="HJMEU:form1:table1:input1" type="text" value="" 
/></td></tr></tbody></table>


-> same client ids for each iteration are generated -> can't work!
I'm using JSF RI 1.1.01 / current myfaces version and it does not seem that the 
panelgrid is the only component having this problem (09.01.2006 16:33: TabPane -> 
Form => Javascript-Error)

Do you have any ideas about that?






Reply via email to