Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
671 views
in Technique[技术] by (71.8m points)

jsf - can't access to suffixs or enum's values in primefaces <p:selectOneMenu component.. any solution?

Hi I am currently working on a java project (jsf) with primefaces and I am using enum, but I cannot access its values from the view with primefaces. I have temporarily solved the problem by creating a getter from the Bean and accessing the enum values, but it should work with allSuffix = "ALL_ENUM_VALUES" or ALL_VALUES by default, I don't know if it's a problem with primefaces, joinfaces or something I'm missing. I have looked into the official documentation and it should work... any solution?

my code is


<p:importEnum
        type="com.path.enumeration.AltoMedioBajo"
        var="AltoMedioBajo"
        allSuffix="ALL_ENUM_VALUES" />

                    <p:outputLabel
                        for="posibilidad"
                        value="#{informe_msg.posibilidad}" />
                    <p:selectOneMenu
                        id="posibilidad"
                        style="width: 150px"
                        value="#{informeSeguimientoDto.specification.posibilidad}">
                        <f:selectItem
                            itemLabel=""
                            itemValue="" />
                        <f:selectItems
                            value="#{AltoMedioBajo.ALL_ENUM_VALUES}"
                            var="posibilidad"
                            itemValue="#{posibilidad}"
                            itemLabel="#{peticion_msg[posibilidad.femKey]}" />
                    </p:selectOneMenu> ```



与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

As per documentation/demo, you should use a repeat tag.

Edited: Try this version:

<p:importEnum type="com.path.enumeration.AltoMedioBajo" var="AltoMedioBajo"
              allSuffix="ALL_ENUM_VALUES" />

<p:outputLabel for="posibilidad" value="#{informe_msg.posibilidad}" />
<p:selectOneMenu id="posibilidad" style="width: 150px"
                 value="#{informeSeguimientoDto.specification.posibilidad}">
    <f:selectItem />
    <ui:repeat var="posibilidad" value="#{AltoMedioBajo.ALL_ENUM_VALUES}">  
        <f:selectItem itemValue="#{posibilidad}"
                      itemLabel="#{peticion_msg[posibilidad.femKey]}"
    </ui:repeat>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...