English 中文(简体)
h:selectOneMenu default value issue when put it in h:dataTable
原标题:

I have a problem with h:selectOneMenu. If I put it in h:dataTable I m unable to set the default value. This is the code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<ui:component xmlns="http://www.w3.org/1999/xhtml"
              xmlns:ui="http://java.sun.com/jsf/facelets"
              xmlns:h="http://java.sun.com/jsf/html"
              xmlns:f="http://java.sun.com/jsf/core">
    <h:dataTable value="#{utenteBean.listaUtenti}"
                 var="utente"  >
        <h:column>
            <f:facet name="header">
                <h:outputText value="#" />
            </f:facet>
            <h:outputText value="1"/>
        </h:column>
        <h:column>
            <f:facet name="header">
                <h:outputText value="#{sW.headerUsername}" />
            </f:facet>
            <h:outputText escape="false"
                          value="#{utente.username}"/>
        </h:column>
        <h:column>
            <f:facet name="header">
                <h:outputText value="#{sW.headerEnabled}" />
            </f:facet>
            <h:form>
                <h:commandLink action="#{utenteBean.updateAbilitato}">
                    <h:outputText value="#{utente.enabled}">
                        <f:converter converterId="abilitatoConverter"/>
                    </h:outputText>
                    <f:setPropertyActionListener target="#{utenteBean.utente}"
                                                 value="#{utente}"/>
                </h:commandLink>
            </h:form>
        </h:column>
        <h:column>
            <f:facet name="header">
                <h:outputText value="#{sW.headerRuolo}" />
            </f:facet>
                <h:form>
                    <h:selectOneMenu value="ROLE_ADMIN"
                                     valueChangeListener="#{utenteBean.updateRuolo}">
                        <f:selectItem itemLabel="Utente" itemValue="ROLE_USER"/>
                        <f:selectItem itemLabel="Admin" itemValue="ROLE_ADMIN"/>
                    </h:selectOneMenu>
                </h:form>
            </h:panelGroup>
        </h:column>
    </h:dataTable>
</ui:component>

If I move the h:form with selectOneMenu out of h:dataTable all works. I m using jsf2.0 on glassfish3

Any Ideas?

问题回答

(Solved by the OP in a question edit. Converted to a community wiki answer. See Question with no answers, but issue solved in the comments (or extended in chat) )

The OP wrote:

I have solved it by myself, i think there is a bug in <h:selectOneMenu value="ROLE_ADMIN" i changed the value="" from static to dynamic with a reference to an istance in managed bean and all work perfectly.





相关问题
Remove all columns with no data from DataTable

If all the items for a particular column are empty, I want to remove that column from the DataTable. What s the most elegant way to do this operation on all columns in the DataTable?

Handle DataTable.DataRow cell change event

I have a DataTable that has several DataColumns and DataRow. Now i would like to handle an event when cell of this DataRow is changed. How to do this in c#?

Customize DataColumn.Expression handling in C#

I would like to change behavior of DataColumn.Expression so that when I write: DataColumn.Expression = "MyMethod(Price)" It will call MyMethod, pass value from Price column into it and display ...

热门标签