Help

Controls

PermLinkWikiLink

Built with Seam

You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.

Forum: Seam Users Forum ListTopic List
19. Aug 2008, 18:20 CET | Link

Hello,

I need some help on adding a selectOneMenu to a page through the bean. The code I have is this:

HtmlSelectOneMenu menu = new HtmlSelectOneMenu();
menu.setValueExpression("value", createValueExpression("#{gestDocuments.selection}", String.class));
				
HtmlSelectItems items = new HtmlSelectItems();
items.setValueExpression("value", createValueExpression("#{gestDocuments.selections}", String.class));

items.setVar("var");
items.setLabel("#{var}");
menu.getChildren().add(items);
dataGroup.getChildren().add(menu);

but with this I'm having an exception:

java.lang.NoClassDefFoundError: org/jboss/seam/ui/component/html/HtmlSelectItems

Help appreciated!

Thank you.

9 Replies:
20. Aug 2008, 13:49 CET | Link

I managed to find another solution to this problem. Instead of adding the SelectOneMenu from the bean, I used conditional rendering.

Alex

25. Aug 2008, 19:51 CET | Link

Well it seams my solution isn't a solution after all. I definitely need to generate the SelectOneMenu in the bean and add it to page.

My code:

HtmlSelectOneMenu select = new HtmlSelectOneMenu();
select.setValueExpression("value", createValueExpression("#{gestDocuments.selection}", String.class));

HtmlSelectItems items = new HtmlSelectItems();
items.setValueExpression("value", createValueExpression("#{gestDocuments.selections}", List.class));
items.setVar("_var");

select.getChildren().add(items);
dataTableGroup.getChildren().add(select); 

I believe the error is lib related but i can't seem to fix it. This is kind of urgent, so please help if you can :)

Thank you

25. Aug 2008, 20:10 CET | Link

I guess you've double check that seam-ui.jar is available on the classpath when you deploy the app.

May you decribe from where you called this code.

25. Aug 2008, 20:16 CET | Link

jboss-seam-ui.jar is in the WEB-INF\lib folder inside the war.

I don't understand the second part of your reply :)

Thank you

26. Aug 2008, 09:00 CET | Link

Hum ...

I mean that if you call this code from an EJB (which I strongly suspect) the classpath is not the same, especially, jboss-seam-ui.jar is in projectDirectory/war/WEB-INF/lib but not in projectDirectory/lib.

While the classpath of your eclipse setup include jboss-seam-ui.jar, thus you cannot see the problem during dev.

Cheers

26. Aug 2008, 10:11 CET | Link

It is being called as a result of an action in a seam component:

@Name("gestDocuments")
@Scope(ScopeType.SESSION)
public class GestaoDocumentsWS{
...

jboss-seam-ui.jar is in project/lib and in the WEB-INF\lib of the war archive.

This is the code:

public void createTable(){
	d = def_proxy.getDefinition(addDefName);

	dataTableGroup = new HtmlPanelGroup();
	
	List<Attribute> att = d.getAtributos();
	
	valores = new Object[att.size()];
	menu = false;
	
	Attribute aux = new Attribute();
	for(int i = 0; i < att.size(); ++i){
		aux = att.get(i);
		System.out.println(aux.getNomeAtributo() + " :: " + aux.getTipoAtributo());
		HtmlOutputText output = new HtmlOutputText();
		output.setValue(aux.getNomeAtributo());
		dataTableGroup.getChildren().add(output);
	
		if(aux.isTipoMenu()){
			System.out.println("TIPO MENU");
			GestaoTiposService s = new GestaoTiposService();
			GestaoTipos p = s.getGestaoTiposPort();
		
			selections = p.getValoresTipo(aux.getTipoAtributo());

			//menu = true;
			
//			HtmlSelectOneMenu select = new HtmlSelectOneMenu();
//			select.setValueExpression("value", createValueExpression("#{gestDocuments.selection}", String.class));
//				
//			HtmlSelectItems items = new HtmlSelectItems();
//			items.setValueExpression("value", createValueExpression("#{gestDocuments.selections}", List.class));
//			items.setVar("_var");
//			
//			select.getChildren().add(items);
//			dataTableGroup.getChildren().add(select);
		}
		else{
			if(aux.getTipoAtributo().equals("DATE")){
				HtmlCalendar myCalendar = new HtmlCalendar();
				myCalendar.setValueExpression("value", createValueExpression("#{gestDocuments.data}", Date.class));
				if(aux.isObrigatorio()){
					myCalendar.setRequired(true);
					myCalendar.setRequiredMessage(aux.getNomeAtributo() + ": Campo de preenchimento obrigatório.");
				}
				dataTableGroup.getChildren().add(myCalendar);
			}else{
				HtmlInputText input = new HtmlInputText();
				if(aux.isObrigatorio()){
					input.setRequired(true);
					input.setRequiredMessage(aux.getNomeAtributo() + ": Campo de preenchimento obrigatório.");
				}
				input.setValueExpression("value", createValueExpression("#{gestDocuments.valores[" + i + "]}", String.class));
				dataTableGroup.getChildren().add(input);
			}				
		}			
	}
}

And I have the same error with HtmlCalendar, although the error happens when I deploy the application while the HtmlSelectOneMenu error only happens when the action is invoked.

26. Aug 2008, 11:07 CET | Link

Ok, I changed a few lines of build.xml file and now I have this:

war\WEB-INF\lib:

  • jboss-seam-debug.jar
  • jboss-seam-gen.jar
  • jboss-seam-ioc.jar
  • jboss-seam-mail.jar
  • jboss-seam-pdf.jar
  • jboss-seam-remoting.jar
  • jboss-seam-ui.jar

ear\lib:

  • antlr-runtime.jar
  • commons-beanutils.jar
  • commons-collections.jar
  • commons-digester.jar
  • commons-lang.jar
  • commons-logging.jar
  • core.jar
  • drools-compiler.jar
  • drools-core.jar
  • janino.jar
  • jboss-el.jar
  • jbpm-jpdl.jar
  • jsf-facelets.jar
  • mvel14.jar
  • richfaces-api.jar
  • richfaces-impl.jar
  • richfaces-ui.jar

HtmlCalendar works fine now, but HtmlSelectItems still gives error.

Thank you.

26. Aug 2008, 11:56 CET | Link

Put jboss-seam-ui in the same place as jsf-facelets.jar . Since richfaces also need to be in the same folder as jsf-facelets.jar put them all in the same place.

Read this excellent article on classloading.

26. Aug 2008, 13:27 CET | Link

Everything is working now :)

Thank you both!