0

first of all sorry for my english, i'll try my best to be understandable. I'm working on a wep app to administrate user profiles. But now I'm stuck at create usergroups. I have an enum class for the rights

public enum UsergroupRights {

  Ja("Ja"),
  Nein("Nein");

  private String rights;

  UsergroupRights(String rights) {
    this.rights = checkRights();
  }

  public String getRights() {
    return rights;
  }
}

a class for the names

public class UsergroupName extends AbstractValueObject<String> {

  public UsergroupName() {
  }

  public UsergroupName(String value) {
    this.value = value;
  }

  @Override
  public String toString() {
    return value;
  }
}

which are stored in an object "usergroups"

public class Usergroup {

  public Usergroup() {
  }

  private UsergroupName name;

  private UsergroupRights rights;

  public Usergroup(UsergroupName name, UsergroupRights rights) {
    this.name = name;
    this.rights = rights;
  }

  public UsergroupName getName() {
    return name;
  }

  public void setName(UsergroupName name) {
    this.name = name;
  }

  public UsergroupRights getRights() {
    return rights;
  }

  public void setRights(UsergroupRights rights) {
    this.rights = rights;
  }

}

and some JSF code

<h:form>
    <h:panelGrid columns="3">
        <h:outputLabel value="Name der Benutzergruppe: " for="usergroupName"/>
        <h:inputText value="#{userData.usergroupName}" id="usergroupName" required="true"/>
        <h:message for="usergroupName" style="color: red"/>

        <h:outputLabel value="Darf Benutzer einsehen: " for="watchUser"/>
        <h:selectOneRadio value="#{userData.usergroupRights.watchUser}" required="true" id="watchUser">
                <f:selectItems value="#{userData.usergroupRightsValues}"/>
        </h:selectOneRadio>
        <h:message for="watchUser"/>

        <h:outputLabel value="Darf Benutzer hinzufügen: " for="addUser"/>
        <h:selectOneRadio value="#{userData.usergroupRights.addUser}" required="true" id="addUser">
            <f:selectItems value="#{userData.usergroupRightsValues}"/>
        </h:selectOneRadio>
        <h:message for="watchUser"/>

        <h:outputLabel value="Darf Benutzer bearbeiten: " for="editUser"/>
        <h:selectOneRadio value="#{userData.usergroupRights.editUser}" required="true" id="editUser">
            <f:selectItems value="#{userData.usergroupRightsValues}"/>
        </h:selectOneRadio>
        <h:message for="watchUser"/>

        <h:outputLabel value="Darf Benutzer löschen: " for="deleteUser"/>
        <h:selectOneRadio value="#{userData.usergroupRights.deleteUser}" required="true" id="deleteUser">
            <f:selectItems value="#{userData.usergroupRightsValues}"/>
        </h:selectOneRadio>
        <h:message for="watchUser"/>

        <h:outputLabel value="Darf Gruppe einsehen: " for="watchUsergroup"/>
        <h:selectOneRadio value="#{userData.usergroupRights.watchUsergroup}" required="true" id="watchUsergroup">
            <f:selectItems value="#{userData.usergroupRightsValues}"/>
        </h:selectOneRadio>
        <h:message for="watchUser"/>

        <h:outputLabel value="Darf Gruppe hinzufügen: " for="addUsergroupR"/>
        <h:selectOneRadio value="#{userData.usergroupRights.addUsergroup}" required="true" id="addUsergroupR">
            <f:selectItems value="#{userData.usergroupRightsValues}"/>
        </h:selectOneRadio>
        <h:message for="watchUser"/>

        <h:outputLabel value="Darf Gruppe bearbeiten: " for="editUsergroups"/>
        <h:selectOneRadio value="#{userData.usergroupRights.editUsergroup}" required="true" id="editUsergroups">
            <f:selectItems value="#{userData.usergroupRightsValues}"/>
        </h:selectOneRadio>
        <h:message for="watchUser"/>

        <h:outputLabel value="Darf Gruppe löschen: " for="deleteUsergroups"/>
        <h:selectOneRadio value="#{userData.usergroupRights.deleteUsergroup}" required="true" id="deleteUsergroups">
            <f:selectItems value="#{userData.usergroupRightsValues}"/>
        </h:selectOneRadio>
        <h:message for="watchUser"/>


        <h:commandButton value="Speichern" id="save" action="#{userData.addUsergroup}"/>
    </h:panelGrid>
</h:form>

Now i want to make a a jsf page where i can add a usergroup name and choose the rights, the usergroup has. It looks like

image

I know that this part "#{userData.usergroupRights.deleteUsergroup}" is not working, but i have no more ideas.

I tried to realize it for a few hours but now i have no more ideas. What can i do, to relate my usergroup name to my usergroup rights?

I hope it was understandable enough.

Greetings

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
NoRatu
  • 1
  • How is this 'enum' related? and especially 'more than one SelectOneRadio in an enum'? I fail to understand the question in relation to the code. And 'is not working' is way to vague... what is the specific **problem** – Kukeltje Dec 17 '15 at 15:52
  • and your `h:message for="..."`is wrong for most inputs – Kukeltje Dec 17 '15 at 16:05
  • My specific problem is that i dont know how to relate the chosen radio buttons to attributes in my enum, when adding a new usergroupRights object and yes my `h:message` components are for testing purposes only – NoRatu Dec 21 '15 at 08:17

0 Answers0