You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by octoberdan <da...@october5th.net> on 2006/05/03 16:44:07 UTC

Re: Picklist problem

Did you get this working?
--
View this message in context: http://www.nabble.com/Picklist-problem-t1122642.html#a4211532
Sent from the MyFaces - Users forum at Nabble.com.


Re: Picklist problem

Posted by octoberdan <da...@october5th.net>.
Oh! and if I use h:hiddenFeild, the form breaks again *rolls eyes*
--
View this message in context: http://www.nabble.com/Picklist-problem-t1122642.html#a4251954
Sent from the MyFaces - Users forum at Nabble.com.


Re: Picklist problem

Posted by octoberdan <da...@october5th.net>.
I messed around with it untill it started working... Assignees is now an
Integer[] and the values in the SelectItems stored in workerItems are now
Integers
--
View this message in context: http://www.nabble.com/Picklist-problem-t1122642.html#a4251947
Sent from the MyFaces - Users forum at Nabble.com.


Re: Picklist problem

Posted by Bruno Aranda <br...@gmail.com>.
And when the form does not submit, do you get any message?

On 5/5/06, octoberdan <da...@october5th.net> wrote:
>
> Does that make sense to you?
> --
> View this message in context: http://www.nabble.com/Picklist-problem-t1122642.html#a4249661
> Sent from the MyFaces - Users forum at Nabble.com.
>
>

Re: Picklist problem

Posted by octoberdan <da...@october5th.net>.
Does that make sense to you?
--
View this message in context: http://www.nabble.com/Picklist-problem-t1122642.html#a4249661
Sent from the MyFaces - Users forum at Nabble.com.


Re: Picklist problem

Posted by octoberdan <da...@october5th.net>.
I think I figured it out... and the answer is a catch 22. If I change
assigneeItems to be a collection of objects of the same class as those
stored in the SelectItem values of the workerItems collection, the page
loads and the desired items are preselected, BUT since assigneeItems and
workerItems are no longer collections of the same type, the form no longer
submits. Weird, huh?
--
View this message in context: http://www.nabble.com/Picklist-problem-t1122642.html#a4249185
Sent from the MyFaces - Users forum at Nabble.com.


Re: Picklist problem

Posted by Bruno Aranda <br...@gmail.com>.
Can you copy the whole stacktrace?

Bruno

On 5/5/06, octoberdan <da...@october5th.net> wrote:
>
> Gah! Further complications! If AssigneeItems isn't empty (as in, it contains
> SelectItems), I get the following exception:
>
> javax.servlet.ServletException: java.lang.ClassCastException:
> javax.faces.model.SelectItem
>
> Any idea what this is about?
> --
> View this message in context: http://www.nabble.com/Picklist-problem-t1122642.html#a4248937
> Sent from the MyFaces - Users forum at Nabble.com.
>
>

Re: Picklist problem

Posted by octoberdan <da...@october5th.net>.
Gah! Further complications! If AssigneeItems isn't empty (as in, it contains
SelectItems), I get the following exception:

javax.servlet.ServletException: java.lang.ClassCastException:
javax.faces.model.SelectItem

Any idea what this is about?
--
View this message in context: http://www.nabble.com/Picklist-problem-t1122642.html#a4248937
Sent from the MyFaces - Users forum at Nabble.com.


Re: Picklist problem

Posted by octoberdan <da...@october5th.net>.
Wow! Can't beleive I missed that... oi. Alright! Everything works wonderfully
and  I don't need the change listener.
--
View this message in context: http://www.nabble.com/Picklist-problem-t1122642.html#a4215704
Sent from the MyFaces - Users forum at Nabble.com.


Re: Picklist problem

Posted by Volker Weber <us...@weber-oldenburg.de>.
you have:

getAssigneeItems

but

setAssignees


octoberdan wrote:
> I should have posted the code:
> 
> Chunk of the java code:
> 
> 	private List<SelectItem> workerItems; 
> 	private List<SelectItem> assigneeItems;
> 	
> 	public List<SelectItem> getAssigneeItems() {
> 		
> 		if (null == assigneeItems) {
> 			List<InvolvedPerson> involvedPeople = getInvolved();
> 			assigneeItems = new ArrayList<SelectItem>();
> 			
> 			for (InvolvedPerson p : involvedPeople) {
> 				assigneeItems.add(new SelectItem(String.valueOf(p.getId()),
> p.getFullName()));
> 			}
> 		}
> 
> 		return assigneeItems;
> 	}
> 	
> 	public void setAssignees(List<SelectItem> assigneeItems) {
> 		this.assigneeItems = assigneeItems;
> 	}
> 	
> 	public void selectionChanged(ValueChangeEvent evt) {
> 		System.out.println(evt.getNewValue());
> 	}
> 
>  	public void setWorkerItems(List<SelectItem> items) {
> 		
> 	}
> 
> JSF code:
> 
> 			<h:outputText value="Assignees: "/>
> 			<s:selectManyPicklist id="assignees"
> value="#{projectCreationBacker.assigneeItems}"
> valueChangeListener="#{projectCreationBacker.selectionChanged}" size="5">
> 				<f:selectItems value="#{projectCreationBacker.workerItems}"/>
> 			</s:selectManyPicklist>
> 			<f:verbatim><br><br></f:verbatim>
> 			
> 			<h:commandButton type="submit" value="Create"
> action="#{projectCreationBacker.create}"/>
> --
> View this message in context: http://www.nabble.com/Picklist-problem-t1122642.html#a4214256
> Sent from the MyFaces - Users forum at Nabble.com.
> 

-- 
Don't answer to From: address!
Mail to this account are droped if not recieved via mailinglist.
To contact me direct create the mail address by
concatenating my forename to my senders domain.

Re: Picklist problem

Posted by octoberdan <da...@october5th.net>.
I should have posted the code:

Chunk of the java code:

	private List<SelectItem> workerItems; 
	private List<SelectItem> assigneeItems;
	
	public List<SelectItem> getAssigneeItems() {
		
		if (null == assigneeItems) {
			List<InvolvedPerson> involvedPeople = getInvolved();
			assigneeItems = new ArrayList<SelectItem>();
			
			for (InvolvedPerson p : involvedPeople) {
				assigneeItems.add(new SelectItem(String.valueOf(p.getId()),
p.getFullName()));
			}
		}

		return assigneeItems;
	}
	
	public void setAssignees(List<SelectItem> assigneeItems) {
		this.assigneeItems = assigneeItems;
	}
	
	public void selectionChanged(ValueChangeEvent evt) {
		System.out.println(evt.getNewValue());
	}

 	public void setWorkerItems(List<SelectItem> items) {
		
	}

JSF code:

			<h:outputText value="Assignees: "/>
			<s:selectManyPicklist id="assignees"
value="#{projectCreationBacker.assigneeItems}"
valueChangeListener="#{projectCreationBacker.selectionChanged}" size="5">
				<f:selectItems value="#{projectCreationBacker.workerItems}"/>
			</s:selectManyPicklist>
			<f:verbatim><br><br></f:verbatim>
			
			<h:commandButton type="submit" value="Create"
action="#{projectCreationBacker.create}"/>
--
View this message in context: http://www.nabble.com/Picklist-problem-t1122642.html#a4214256
Sent from the MyFaces - Users forum at Nabble.com.


Re: Picklist problem

Posted by octoberdan <da...@october5th.net>.
As for messages I'm getting:
'Bean: com.loomis.jsf.backingbean.ProjectCreationBackingBean, property:
assigneeItems'
Does that make sense?
--
View this message in context: http://www.nabble.com/Picklist-problem-t1122642.html#a4214365
Sent from the MyFaces - Users forum at Nabble.com.


Re: Picklist problem

Posted by Volker Weber <us...@weber-oldenburg.de>.
octoberdan wrote:
> Alright. I'm using an valueChangeListener, it works and everything's groovy
> on that side of things, but the form's action method is no longer being
> called. What would be a possible reason for this?

Possible reasons for skipping ApplicationPhase:

Validation errors : put a <t:messages> on your page to see them!

Conversion errors : put a <t:messages> on your page to see them!

calling of facesContext.renderResponse() somewehre in your code!

> --
> View this message in context: http://www.nabble.com/Picklist-problem-t1122642.html#a4213794
> Sent from the MyFaces - Users forum at Nabble.com.
> 

-- 
Don't answer to From: address!
Mail to this account are droped if not recieved via mailinglist.
To contact me direct create the mail address by
concatenating my forename to my senders domain.

Re: Picklist problem

Posted by octoberdan <da...@october5th.net>.
Alright. I'm using an valueChangeListener, it works and everything's groovy
on that side of things, but the form's action method is no longer being
called. What would be a possible reason for this?
--
View this message in context: http://www.nabble.com/Picklist-problem-t1122642.html#a4213794
Sent from the MyFaces - Users forum at Nabble.com.


Re: Picklist problem

Posted by Bruno Aranda <br...@gmail.com>.
Yes, the example uses a valueChangeListener and no value attribute.
There is the valueChangeListener only to check the items selected and
update the info string. If you pass a value with an array of String
(the selected values) as the value attribute of the picklist, those
values will be preselected when the component is rendered. If you
don't want any item preselected, just don't pass a value.
Look at the sources of the example (jsp [1] and backing bean [2]), and
if you need more detailed information, refer to the selectManyListbox
documentation [3].

Regards,

Bruno

[1] http://www.irian.at/myfaces-sandbox/picklist.jsp.source
[2] http://svn.apache.org/viewcvs.cgi/*checkout*/myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/picklist/PicklistBean.java?content-type=text%2Fplain
[3] http://java.sun.com/javaee/javaserverfaces/1.1_01/docs/tlddocs/h/selectManyListbox.html

On 5/3/06, octoberdan <da...@october5th.net> wrote:
>
> but that's with a valueChangeListener... can't you just set the value to be
> an array?
> --
> View this message in context: http://www.nabble.com/Picklist-problem-t1122642.html#a4212085
> Sent from the MyFaces - Users forum at Nabble.com.
>
>

Re: Picklist problem

Posted by octoberdan <da...@october5th.net>.
but that's with a valueChangeListener... can't you just set the value to be
an array?
--
View this message in context: http://www.nabble.com/Picklist-problem-t1122642.html#a4212085
Sent from the MyFaces - Users forum at Nabble.com.


Re: Picklist problem

Posted by Bruno Aranda <br...@gmail.com>.
Yes, in the myfaces demo app  [1] you can see the picklist working,
and it is using a backing bean,

Cheers,

Bruno

[1] http://www.irian.at/myfaces-sandbox/picklist.jsf;jsessionid=5C28CD0822F1C421233495C8EF9263DB

On 5/3/06, octoberdan <da...@october5th.net> wrote:
>
> Did you get this working?
> --
> View this message in context: http://www.nabble.com/Picklist-problem-t1122642.html#a4211532
> Sent from the MyFaces - Users forum at Nabble.com.
>
>