javaserverfaces
  1. javaserverfaces
  2. JAVASERVERFACES-1978

wrong id for h:selectOneMenu inside composite in h:dataTable

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Works as designed
    • Affects Version/s: 2.0.4, 2.1.0
    • Fix Version/s: None
    • Component/s: facelets
    • Labels:
      None
    • Status Whiteboard:
      Hide

      size_medium importance_medium

      Show
      size_medium importance_medium

      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" ...

        Activity

        Hide
        Manfred Riem added a comment -

        Closing resolved issue out

        Show
        Manfred Riem added a comment - Closing resolved issue out
        Hide
        lamine_ba added a comment -

        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...

        Show
        lamine_ba added a comment - 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...
        Hide
        lamine_ba added a comment - - edited

        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");
        .....................
        
        }
        
        }
        
        Show
        lamine_ba added a comment - - edited 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" ); ..................... } }

          People

          • Assignee:
            Ed Burns
            Reporter:
            ymajoros
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: