[jboss-user] [JBoss Seam] - Error selecting object problem
jamesjmp
do-not-reply at jboss.com
Tue Nov 6 12:28:08 EST 2007
hi,
In a form I´ve a h:selectOneMenu which is filled according to the values of a List.
| <s:decorate id="firmCodeDecoration" template="layout/edit.xhtml">
| <ui:define name="label">#{messages['Firm']}</ui:define>
| <h:selectOneMenu value="#{rstReportHome.instance.firm}" required="true" id="firm">
| <s:selectItems value="#{firmList.resultList}" var="firm" label="#{firm.firmCode}" />
| <s:convertEntity/>
| <a:support event="onchange" reRender="firmCodeDecoration"/>
| </h:selectOneMenu>
| </s:decorate>
|
Component firmList is seam-gened with just a simple query this way:
| @Override
| public String getEjbql() {
| return "select firm from Firm firm";
| }
I want in my selectOneMenu to display all the values of table Firm, but I do want an extra value as well.
Let´s call it "Automatic".
I´ve added the following to component firmList:
| @Override
| public List<Firm> getResultList() {
| System.out.println("firmList getResultList!!");
| Firm auto = new Firm();
| auto.setFirmCode("AUTOMATIC");
| CfgCurrency cfgCurrency = new CfgCurrency();
| cfgCurrency.setCurrencyCode(60);
| auto.setCfgCurrency(cfgCurrency);
| List<Firm> firmas = new ArrayList<Firm>();
| firmas.add(auto);
| firmas.addAll(super.getResultList());
| System.out.println("firmas.size: "+firmas.size());
| return firmas;
| }
|
After adding this, selectOneMenu displays AUTOMATIC value as well as the rest retrieved by the query.
But when I press a button that performs persist() ajax validation displays red message besides with "Error selecting object" only If I choose Automatic option.
I guess it must be something related with s:convertEntity, but I´m not sure how to tackle it.
This is firm object:
| @Entity
| @Table(name = "FIRM", catalog = "prisk")
| public class Firm implements java.io.Serializable {
|
| private String firmCode;
| private CfgCurrency cfgCurrency;
| private String firmDescription;
| private Set<RstReport> rstReports = new HashSet<RstReport>(0);
| private Set<Fund> funds = new HashSet<Fund>(0);
|
| public Firm() {
| firmCode = "";
| firmDescription = "";
| }
|
What is the best way to add an extra value (apart from those provided by the query) to be displayed in a selectOneMenu?
If overriding getResultList is one of the ways, why I´m having that validation problem?
thanks in advance!
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4102282#4102282
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4102282
More information about the jboss-user
mailing list