0

My problem is about this primefaces tag:

<p:selectManyCheckbox id="datasourceGroup" value="#{sessionBean.datasourceGroups}" converter="datasourceGroupConverter">
  <f:selectItems value="#{sesionBean.getAllDatasourceGroups()}" var="group" itemLabel="#{group.toString()}" itemValue="#{group}" />  
</p:selectManyCheckbox>                         

It does not render any visible output (checkboxes) at all. From logging output i know that the 'sessionBean.getAllDatasourceGroups()' method is not even called once during page refresh. only the 'sessionBean.getDatasourcegroups()' getter for the 'datasourceGroups' property is called once.

And i can't figure out what the problem is. I have very similar usecases of <p:selectManyMenu> and <p:selectOneMenu> on the same page and they work fine. So i have a basic understanding of how this works...or so i thought :-)

here are the other relevant parts of the code for reference:

SessionBean:

@ManagedBean
@SessionScoped
public class SessionBean implements Serializable {

    private List<DatasourceGroup> datasourceGroups = new ArrayList<>();

    public List<DatasourceGroup> getDatasourceGroups() {
        return datasourceGroups;
    }

    public void setDatasourceGroups(List<DatasourceGroup> datasourceGroups) {
        this.datasourceGroups = datasourceGroups;
    }

    public List<DatasourceGroup> getAllDatasourceGroups() {
        List<DatasourceGroup> list = Arrays.asList(DatasourceGroup.values());
        return list;
    }
}

DatasourceGroup Enum:

public enum DatasourceGroup {

    KUNDEN (Permission.ZugriffKunden),
    INKASSO (Permission.ZugriffInkasso),
    INTERESSENTEN (Permission.ZugriffInteressenten),
    WARN (Permission.ZugriffWarnadressen);

    private Permission permissionNeeded;

    DatasourceGroup(Permission permission) {
        this.permissionNeeded=permission;
    }

    public Permission getPermissionNeeded() {
        return permissionNeeded;
    }

}

And the DatasourceGroupConverter:

@FacesConverter("datasourceGroupConverter")
public class DatasourceGroupConverter implements Converter {

    @Override
    public Object getAsObject(FacesContext fc, UIComponent uic, String value) {

        if (Toolbox.isNullOrEmpty(value))
            return null;

        try {
            return DatasourceGroup.valueOf(value);
        } catch (IllegalArgumentException e) {
            throw new ConverterException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Conversion Error:",
                    "'" + value + "' is not a valid datasource group name"));
        }
    }

    @Override
    public String getAsString(FacesContext fc, UIComponent uic, Object object) {
        if(object != null && object instanceof DatasourceGroup) {
            return ((DatasourceGroup)object).toString();
        }
        return null;
    }

}

I'm using primefaces 6.0 by the way.

Mario Köhler
  • 192
  • 1
  • 10
  • Did you run your application in development mode? Please do, most likely you get an error then. Hint: You have a typo... sesionBean instead of sessionBean in your `f:selectItems... ` – Kukeltje Apr 05 '17 at 10:27
  • You gotta be f*** kidding me...yes, the typo was the reason why it didn't work. *sigh* Do you have any idea how long i looked over that code before posting it here? :-) btw, i was in Development mode but no error about the typo. BIG thanks! – Mario Köhler Apr 05 '17 at 11:10
  • Seriously no error? That is very weird... Worth a new question specifically about that. Maybe @BalusC knows. What JSF implementation and version are you running? And a good IDE should have 'warned' you about this. – Kukeltje Apr 05 '17 at 11:12
  • Hmm...but i have this in my web.xml: ` facelets.DEVELOPMENT true ` ... is that not the right way to activate Development mode? – Mario Köhler Apr 05 '17 at 11:25
  • I'm using eclipse neon.3 as IDE...i'm a bit surprised myself that eclipse didn't catch the typo. I'm using the JSF implementation that comes with glassfish 4...i believe it's Mojarra 2.2.12 – Mario Köhler Apr 05 '17 at 11:27

0 Answers0