5 Replies Latest reply on Jan 22, 2011 7:24 AM by pouria kazemi

    problem with selectmanycheckbox

    pouria kazemi Newbie
      hi experts today i encountered another problem with selectmanycheckbox ;the snippet code including

      <h:selectManyCheckbox value="#{conversationBean.oneList}">
          <s:selectItems  value="#{conversationBean.anotherList}" var="something" label="#{something.name}">
      </s:selectItems>
      </h:selectManyCheckbox>


      and now i need to persist a list of selected(checked) from conversationBean.anotherList into conversationBean.oneList . i don,t know how to? please F1 me.(i mean i,m really get in trouble and really need your help)
        • 1. Re: problem with selectmanycheckbox
          Earnest Dyke Novice

          By definition, oneList should contain all of the selected objects from anotherList after the page is processed.


          Earnie!

          • 2. Re: problem with selectmanycheckbox
            pouria kazemi Newbie

            thanks for your reply.i know your mentioned things but i cannot persist oneList . excuse me but i really do not understand what exactly you mean?would you please more explain?

            • 3. Re: problem with selectmanycheckbox
              Earnest Dyke Novice

              What do you mean by i cannot persist oneList? Do you mean oneList is empty when the page is processed? Or are you trying to save it to a database and do not know how to?


              Earnie!

              • 4. Re: problem with selectmanycheckbox
                omid pourhadi Apprentice

                Hi,
                use


                <s:convertEntity />



                if your conversationBean.oneList comes from Entity
                and use



                <s:convertEnum />



                if your conversationBean.oneList comes from Enum class
                and if you r extending EntityHome seam take cares of persistence


                and one last thing please DO NOT cross posting (double post)

                • 5. Re: problem with selectmanycheckbox
                  pouria kazemi Newbie
                  more details of my problem is :
                  my xhtml tags :
                  <rich:dataTable var="_se" value="#{positionTypeSeverityConversation.GetSeverityTypeName()}">
                     <h:column>
                          <h:outputText value="#{_se.name}" />
                     </h:column>
                    <h:column>
                    <h:selectManyCheckbox  id="severityList" onchange="submit()"
                       value="#{positionTypeSeverityConversation.?">
                  ----> here i dont know what to place with ? (?=someKinfOfList)
                  <s:selectItems var="_seList"
                        value="#{positionTypeSeverityConversation.GetSeverityList(_se.id)"
                        label="#{_se.name}" />

                     <s:convertEntity />
                  </h:selectManyCheckbox>
                     
                    </h:column>
                    </rich:dataTable>
                     </h:panelGrid>
                    </rich:panel>

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

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

                  with this tag ---> <s:selectItems var="_seList"
                  value="#{positionTypeSeverityConversation.GetSeverityList(_se.id)"

                      label="#{_se.name}" />   i fill  list check box. and user can select of them.my problem is to sending  id's of severityhai's which was selected to

                  --->   <h:selectManyCheckbox  id="severityList" onchange="submit()"

                  value="#{positionTypeSeverityConversation.?">. and atleast i should persist severity's at PositionTypeSeverity table.well i have 3 tables 1-Severity 2-SeverityType 3-PositionTypeSeverity and 1-Severity with 2-SeverityType has n--->1  relation And  1-Severity with 3-PositionTypeSeveity  has 1---->n relation.

                   

                  @Stateful
                  @Scope(ScopeType.CONVERSATION)
                  @Name("positionTypeSeverityConversation")
                  public class PositionTypeSeverityConversationBean implements
                     PositionTypeSeverityConversation, Serializable {

                  private static final long serialVersionUID = -3604911984259043624L;
                  @Logger

                  private Log log;
                  @In
                  private EntityManager entityManager;
                  private PositionTypeSeverity positionTypeSeverity;
                  private SeverityType severityType;


                  @SuppressWarnings("unchecked")
                  public List<SeverityType> GetSeverityTypeName(){
                    return (List<SeverityType>) this.entityManager.createQuery(
                  "   from SeverityType s ("
                  .        getResultList();

                                  
                                    {
                   

                  @SuppressWarnings("unchecked")
                  public List<SeverityType> GetSeverityList(long id) {
                    return (List<Severity>) this.entityManager.createQuery(
                  "   from Severity s where s.severityType.id = :id("
                  .      setParameter("id", id(
                  .        getResultList();

                                  
                                    {
                        ...

                   

                  with a hql query i did  select from Severity and show the list in ---><s:selectItems var="_seList"

                  value="#{positionTypeSeverityConversation.GetSeverityList(_se.id)"

                      label="#{_se.name}" /> and do not know how to persist severity's which selectd . i need a  java method  to persist them.and i know i should send id of the severity's which selected to a list but i couldnt find good example most people use static list to show items and send a name to selectmanycheckbox value;