[jboss-user] [JBoss jBPM] - [Workaround] Re: Combo Box in Form

karstendausb do-not-reply at jboss.com
Tue Sep 4 21:06:41 EDT 2007

"kukeltje" wrote : please.... what is so difficult about my previous post.... this is JSF stuff, not jBPM. So please ask in the correct forum and learn JSF!!!! 

I wouldn't say this is totally wrong, but it is pretty far away from the truth, as jBPM is probably very well involved in this problem.

I ran into the same problem today, and spent many hours to figure this out. There are many postings in this forum, but not a solution. I will describe  a workaround and one possible cause for this problem.

jbpm-3.2.1-ear on jboss 4.0.4

Same problem as Riket44: After adding a collection of SelectItem as a process variable like this in an  actionhandler

  | Collection selectItems=new ArrayList();
  | selectItems.add(new SelectItem("BLA","Fasel"));
  | selectItems.add(new SelectItem("BLoe","Fasel2"));
  | executionContext.getContextInstance().createVariable("selectit1",selectItems);
using it in a task form like this:

  | ...
  |  <h:selectOneMenu id="bla22" value="#{var['userselection']}">
  | <f:selectItems value="#{var['selectit1']}" />		
  | </h:selectOneMenu>
  | ...
got me this Exception:

  | java.lang.IllegalArgumentException: Argument Error: An option for component j_id48 was not an instance of javax.faces.model.SelectItem. Type found: java.util.ArrayList.

I also tried
* List of SelectItem
* Collection of SelectItem
* SelectItem []
,all with similar Exceptions.

When I changed the form to

  |  <h:selectOneMenu id="bla22" value="#{var['userselection']}">
  | <f:selectItem value="#{var['selectit1'][0]}" />		
  | </h:selectOneMenu>

I got this very nice Exception:

  | java.lang.IllegalArgumentException: "Argument Error: An option for component bla22 was not an instance of javax.faces.model.SelectItem.  Type found: javax.faces.model.SelectItem.
  | 	at com.sun.faces.renderkit.RenderKitUtils.getSelectItems(RenderKitUtils.java:315)

Wow. How is that?  It is not a SelectItem, it is a  SelectItem!

Looking at RenderKitUtils.java  I found that the comparison
 (value instanceof SelectItem)  must have returned false. This is weired, because instances of javax.faces.model.SelectItem is exactly what has been put into the collection in the actionhandler.

I am not sure what causes this. I first thought that it would be a persistence-related classloading problem (persistence layer using myfaces-jars from tomcat-sar instead of sun's ri vom jbpm-ear), but that doesn't seem to the problem: I replaced the myfaces-jars in tomcat-sar/jsf-libs with the sun-ri-jars, but that didn't help. 

Any ideas? I would love to here the solution to this (not only, but especially from Ronald (time to prove that this is a JSF-problem ;-)) ?

Ah, I promised a workaround:
Furtheron in the code, I found that the value attribute of SelectItems also takes a map (key->label, value->value). So I tried this one, and that worked like it was expected to be:

  | Map mymap=new HashMap();
  | mymap.put("bla", "fasel");
  | executionContext.getContextInstance().createVariable("selectit1",mymap);
in the handler.
And the snippet

  |  <h:selectOneMenu id="bla22" value="#{var['userselection']}">
  | <f:selectItems value="#{var['selectit1']}" />		
  | </h:selectOneMenu>
in the form.

Hope this helps, but I would very much appreciate a proper solution!

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4081146#4081146

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4081146

More information about the jboss-user mailing list