[
http://issues.apache.org/jira/browse/MYFACES-716?page=comments#action_12332565
]
Sharath Reddy commented on MYFACES-716:
---------------------------------------
Hi Vinnie,
I tried to reproduce your setup exactly. This is my JSF:
<f:subview id="results">
<h:form>
<x:dataList
var="country"
value="#{countryList.countries}"
layout="orderedList">
<h:selectBooleanCheckbox value="#{country.isDemocracy}"/>
<h:commandLink action="#{country.printName}">
<h:outputText value="#{country.name}"/>
</h:commandLink>
</x:dataList>
</h:form>
</f:subview>
I did a 'view source'. In my case, the HMTL ids are generated correctly:
<li><input type="checkbox" name="results:_id0:_id1_0:_id2" value="true" />
<a href="#"
onclick="clear_results_3A_5Fid0();document.forms['results:_id0'].elements['autoScroll'].value=getScrolling();document.forms['results:_id0'].elements['results:_id0:_link_hidden_'].value='results:_id0:_id1_0:_id3';if(document.forms['results:_id0'].onsubmit){if(document.forms['results:_id0'].onsubmit())
document.forms['results:_id0'].submit();}else{document.forms['results:_id0'].submit();}return
false;" id="results:_id0:_id1_0:_id3">AUSTRIA</a></li>
<li><input type="checkbox" name="results:_id0:_id1_1:_id2" value="true" />
<a href="#"
onclick="clear_results_3A_5Fid0();document.forms['results:_id0'].elements['autoScroll'].value=getScrolling();document.forms['results:_id0'].elements['results:_id0:_link_hidden_'].value='results:_id0:_id1_1:_id3';if(document.forms['results:_id0'].onsubmit){if(document.forms['results:_id0'].onsubmit())
document.forms['results:_id0'].submit();}else{document.forms['results:_id0'].submit();}return
false;" id="results:_id0:_id1_1:_id3">AZERBAIJAN</a></li>
However, the action method that you are trying to call, "#{current.display}",
is defined on each individual item in your list. I dont think this is going to
work. I got the following error when trying to execute the action:
Error calling action method of component with id results:_id0:_id1_1:_id3
Regards,
Sharath
> Problem using JSF input components with DataList
> ------------------------------------------------
>
> Key: MYFACES-716
> URL: http://issues.apache.org/jira/browse/MYFACES-716
> Project: MyFaces
> Type: Bug
> Versions: Nightly
> Reporter: Vinnie Fazio
>
> I was using the Tomahawk 20050912 nightly build when I first noticed this
> bug. I have since upgraded to the nightly build from 20051017 and am
> experiencing the same issue.
> THE PROBLEM:
> =============
> Here is the JSF I am using:
> <f:subview id="results">
> <h:form>
> <x:dataList value="#{myList}" var="current" layout="orderedList" >
> <h:selectBooleanCheckbox value="#{current.selected}"/>
> <h:commandLink action="#{current.display}">
> <h:outputText value="#{current.name}"/>
> </h:commandLink>
> </x:dataList>
> </h:form>
> </f:subview>
> ADDITIONAL INFO
> ===============
> The html seems to be look OK, but when I select an item (either the link or
> the checkbox) and the form is submitted, the value referenced is always the
> first value from the list. A closer look at the HTML source shows that all
> the ids (names) generated are the same...
> <li><input type="checkbox" name="results:_id27:_id43:_id44" /><a href="#"
> onclick="document.forms['results:_id27']['results:_id27:_idcl'].value='results:_id27:_id43:_id45';
> document.forms['results:_id27'].submit(); return false;">Value1</a></li>
> <li><input type="checkbox" name="results:_id27:_id43:_id44" /><a href="#"
> onclick="document.forms['results:_id27']['results:_id27:_idcl'].value='results:_id27:_id43:_id45';
> document.forms['results:_id27'].submit(); return false;">Value2</a></li>
> <li><input type="checkbox" name="results:_id27:_id43:_id44" /><a href="#"
> onclick="document.forms['results:_id27']['results:_id27:_idcl'].value='results:_id27:_id43:_id45';
> document.forms['results:_id27'].submit(); return false;">Value3</a></li>
> If I change the datalist to a h:datatable I get html with unique ids and all
> the links work correctly. For instance...
> <tr>
> <td><input type="checkbox" name="results:_id27:_id43:0:_id45" /><a href="#"
> onclick="document.forms['results:_id27']['results:_id27:_idcl'].value='results:_id27:_id43:0:_id46';
> document.forms['results:_id27'].submit(); return false;">Value1</a></td>
> </tr>
> <tr>
> <td><input type="checkbox" name="results:_id27:_id43:1:_id45" /><a href="#"
> onclick="document.forms['results:_id27']['results:_id27:_idcl'].value='results:_id27:_id43:1:_id46';
> document.forms['results:_id27'].submit(); return false;">Value2</a></td>
> </tr>
> <tr>
> <td><input type="checkbox" name="results:_id27:_id43:2:_id45" /><a href="#"
> onclick="document.forms['results:_id27']['results:_id27:_idcl'].value='results:_id27:_id43:2:_id46';
> document.forms['results:_id27'].submit(); return false;">Value3</a></td>
> </tr>
> I HAVE TRIED
> ============
> - I have tried setting the forceIDIndex field to true and it did not change
> anything.
> - I noticed in similar bug that the user posted a workaround of surrounding
> the input components with <h:column>, but that did not work either.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira