2 Replies Latest reply on Jan 31, 2011 12:27 AM by pouria kazemi

    how to show h:selectmanycheckbox items checked

    pouria kazemi Newbie

      Hi dear experts
      my new problem is  how to show h:selectmanycheckbox items checked.
      i want  the h:selectmanycheckbox to  be selected initially when displaying the page. would you experts guide ?

        • 1. Re: how to show h:selectmanycheckbox items checked
          Tim Evers Master

          Just make sure whatever value they are binding back to has the value true.


          Instead of asking how to do something. Think about your problem and try to write something. Then when you get stuck post what you have and ask why it doesn't work.

          • 2. Re: how to show h:selectmanycheckbox items checked
            pouria kazemi Newbie
            here is my java code which i wish it check my checkbox but it didnt.

                    private long positionTypeId;

                 public long getPositionTypeId() {
                      if (this.positionType != null)
                           return this.getPositionType().getId();
                      else
                           return 0;
                 }

                 public void setPositionTypeId(long value) {
                      this.positionTypeId = value;

                      this.positionType = this.entityManager.find(PositionType.class,
                                this.positionTypeId);
                      
                      this.selectedOptions.clear();
                      
                      for (PositionTypeSeverity sev : this.positionType.getPositionTypeSeverity()) {
                           Long sev_id = sev.getId();
                           
                           this.selectedOptions.add(sev_id);
                      }
                      

                 }

            <h:form id="positionTypeSeverityAdd" styleClass="edit">
            <rich:panel>
               <h:panelGrid>
            <h:outputText value="#{positionTypeSeverityConversation.positionType.name}" />

            <h:selectManyCheckbox id="severity" value="#{positionTypeSeverityConversation.selectedOptions}">
            <s:selectItems var="_ser" value="#{positionTypeSeverityConversation.severities}"
            label="#{_ser.name}" itemValue="#{_ser.id}"  />
            </h:selectManyCheckbox>
            </h:panelGrid>
            </rich:panel>

            <h:commandButton id="save" value="Save"
                 action="#{positionTypeSeverityConversation.save()}"
                 style="FONT-FAMILY: 'Abyssinica SIL';">
            </h:commandButton>

            <s:button view="/setting/hr/PositionType.xhtml" id="cancelAdd"
                 value="Cancel">
                 <f:param name="positionTypeId" value="#{positionTypeId}" />
            </s:button>
            </h:form>