<< Back to previous view

[JAVASERVERFACES-1978] wrong id for h:selectOneMenu inside composite in h:dataTable Created: 09/Mar/11  Updated: 23/Mar/12  Resolved: 02/Jun/11

Status: Closed
Project: javaserverfaces
Component/s: facelets
Affects Version/s: 2.0.4, 2.1.0
Fix Version/s: None

Type: Bug Priority: Major
Reporter: ymajoros Assignee: Ed Burns
Resolution: Works as designed Votes: 0
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Status Whiteboard:

size_medium importance_medium

Tags:
Participants: Ed Burns, lamine_ba, Manfred Riem and ymajoros

 Description   

<h:dataTable value="#{controller.authorizations}" var="authorization">
<h:column>
<my:auth value="#{authorization.authType}" />
</h:column>
</h:dataTable>

Composite component implementation is just a f:selectOneMenu with hardcoded f:selectItem values (enum values).

Behavior with composite component (wrong):

Rendered output has same id for select on each row:
<select id="j_idt25:j_idt48:j_idt72:_t73" ...

When putting implementation of composite component directly in dataTable column (right):

<select id="j_idt25:j_idt48:0:_t72" ...
...
<select id="j_idt25:j_idt48:1:_t72" ...



 Comments   
Comment by lamine_ba [ 02/Jun/11 02:25 PM ]

auth.xhtml (resources/tags/auth.xhtml)

<html xmlns="http://www.w3.org/1999/xhtml"   
      xmlns:cc="http://java.sun.com/jsf/composite"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html" >
 
     <cc:interface>
    	<cc:attribute name="value" required="true"/>
     </cc:interface>
  
    <cc:implementation>
			
         <h:selectOneMenu  value="#{cc.attrs.value}">
                      
             <f:selectItems value="#{controller.authTypes}" />

         </h:selectOneMenu>
	  
	<cc:insertChildren />
	
 </cc:implementation>
	  
</html>

MAIN_PAGE.XHTML

<!DOCTYPE html PUBLIC "-//W3C//DTD
XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/ ..
xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html" 
xmlns:my="http://java.sun.com/jsf/composite/tags">


<body>

<h:form>

<h:dataTable value="#{controller.authorizations}" var="authorization">
<h:column>
<my:auth value="#{authorization.authType}" />
</h:column>
</h:dataTable>
</h:form>

</body>

</html>

rendering output

<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<form id="j_idt6" name="j_idt6"
 method="post" action="/server/faces/test.xhtml"
 enctype="application/x-www-form-urlencoded">

<input type="hidden" name="j_idt6" value="j_idt6" />
<table>
<tbody>
<tr>
<td><select name="j_idt6:j_idt8:0:j_idt10:j_idt11" size="1">	

	<option value="1">Value 1</option>
	<option value="2">Value 2</option>

</select></td>
</tr>
<tr>
<td><select name="j_idt6:j_idt8:1:j_idt10:j_idt11" size="1">	

	<option value="1">Value 1</option>
	<option value="2">Value 2</option>


</select></td>
</tr>
<tr>
<td><select name="j_idt6:j_idt8:2:j_idt10:j_idt11" size="1">	

	<option value="1">Value 1</option>
	<option value="2">Value 2</option>


</select></td>
</tr>
<tr>
<td><select name="j_idt6:j_idt8:3:j_idt10:j_idt11" size="1">	
	<option value="1">Value 1</option>
	<option value="2">Value 2</option>

</select></td>
</tr>
</tbody>
</table>

</form>

</body>

</html>

I don't see the wrong id for h:selectOneMenu inside composite in h:dataTable and by default the MenuRenderer in mojarra render the id of a h:selectXXX component only if you set it yourself.

public class MenuRenderer extends HtmlBasicInputRenderer {

protected void renderSelect(FacesContext context,
                                UIComponent component) throws IOException {

        ResponseWriter writer = context.getResponseWriter();
        writer.startElement("select", component);
        writeIdAttributeIfNecessary(context, writer, component);
        writer.writeAttribute("name", component.getClientId(context),
                              "clientId");
.....................

}

}
Comment by lamine_ba [ 02/Jun/11 03:26 PM ]

I'm closing this issue because I don't have the problem described by the user.
I have reproduced the problem and everything was fine...

Comment by Manfred Riem [ 23/Mar/12 05:05 PM ]

Closing resolved issue out

Generated at Sun Apr 20 10:18:24 UTC 2014 using JIRA 4.0.2#472.