-
1. Re: Where is selected=true on s:selectItems ?
stephen May 16, 2008 9:14 PM (in response to cash1981)Not really a Seam question, but anyway:
The selectItems tag is only used to specify the complete set of items (selected plus unselected).You specify the selected subset by using the value attribute of the selectManyCheckbox.
Google for examples.
-
2. Re: Where is selected=true on s:selectItems ?
nickarls May 16, 2008 9:21 PM (in response to cash1981)Haven't used selectManyCheckbox in a while but probably it's selected when the items value matches the value of target binding (which you don't have on your tag)
-
3. Re: Where is selected=true on s:selectItems ?
cash1981 May 17, 2008 11:58 AM (in response to cash1981)Huh? Im not sure what you mean here.
The items value matches value of the target binding? Could you please explain how I do this?
-
4. Re: Where is selected=true on s:selectItems ?
cash1981 May 17, 2008 11:59 AM (in response to cash1981)Huh? Im not sure what you mean here.
The items value matches value of the target binding? Could you please explain how I do this?
-
5. Re: Where is selected=true on s:selectItems ?
cash1981 May 17, 2008 12:01 PM (in response to cash1981)
Stephen Friedrich wrote on May 16, 2008 09:14 PM:
Not really a Seam question, but anyway:
The selectItems tag is only used to specify the complete set of items (selected plus unselected).
You specify the selected subset by using the value attribute of the selectManyCheckbox.
Google for examples.I have googled and googled, but no examples shows me a selectManyCheckBox that is default selected. The selectManyCheckbox does not take a selected as an attribute.
How can I use the value attribute to make it selected? -
6. Re: Where is selected=true on s:selectItems ?
stephen May 17, 2008 2:59 PM (in response to cash1981)<h:selectManyCheckbox rendered="#{proeveTypeSokList != null and proeveTypeSokList.size > 0}" value="#{aListOfAllSelectedElementsThisWillBeInititiallyReadFromToDetermineTheDefaultSelectionAndTheNewSelectionWillBeWrittenToItWhenTheFormIsSubmitted}"> <s:selectItems value="#{proeveTypeSokList}" var="proevetype" label="#{proevetype.beskrivelse}"/> </h:selectManyCheckbox>
-
7. Re: Where is selected=true on s:selectItems ?
cash1981 May 19, 2008 10:48 AM (in response to cash1981)Thank you Stephen. That did it.
-
8. Re: Where is selected=true on s:selectItems ?
cash1981 May 19, 2008 1:57 PM (in response to cash1981)I got the result I wanted now, but I have one problem which I need help with...
My xhmtl now looks like this:
<h:selectManyCheckbox value="#{provetypeSelectedList}"> <s:selectItems value="#{proevetypeSokList}" var="proevetype" label="#{proevetype.beskrivelse}"/> </h:selectManyCheckbox> <h:commandButton id="findProever" value="Find Proeve" action="#{searchRegisterManager.find}" reRender="searchResults" />
The provetypeSelectedList and proevetypeSokList contain the same values since I wanted all the elements in the checkbox to be default set.
My action looks like this:
@Out(required=false) private List<Proevetype> proevetypeSokList; @Out(required=false) private List<Proevetype> provetypeSelectedList; @Factory(value= "proevetypeSokList") public void findProevetyper() { proevetypeSokList = em.createQuery("from " + Proevetype.class.getName() + " pt ").getResultList(); } @Factory(value= "provetypeSelectedList") public void findProevetypeSelected() { provetypeSelectedList = em.createQuery("from " + Proevetype.class.getName() + " pt ").getResultList(); } public void find() { for (Proevetype pt : provetypeSelectedList) { System.out.println("Value of pt: " + pt.getId()); } }
Now the problem is that if you uncheck some of the values from the checkbox and submit the form, it still retrieves the whole list, but not the ones I selected.
What am I doing wrong here?