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.
| Online: | 17 Members of 4546 |
| Forum: Seam Users |
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.
I managed to find another solution to this problem. Instead of adding the SelectOneMenu from the bean, I used conditional rendering.
Alex
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
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.
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
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
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.
Ok, I changed a few lines of build.xml file and now I have this:
war\WEB-INF\lib:
ear\lib:
HtmlCalendar works fine now, but HtmlSelectItems still gives error.
Thank you.
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.
Everything is working now :)
Thank you both!