<s:selectItems>
cormet Jul 3, 2007 9:06 PMHi All,
I having problem in converting the object from dropdown menu. I have seen the example in UI section. however, it did the same and I got the error message "Error selecting object". The drop menu listed all account types but when i click submit button, i got that error message. Looks like the converter is not running correctly.
I am currently using Hibernate, Seam 1.2.1 and AS 4.0.5.
here are my snippet code.
<s:decorate id="typeDecorate" template="/edit.xhtml"> <ui:define name="label">Account Type:</ui:define> <h:selectOneMenu id="type" value="#{account.accountType}"> <s:selectItems value="#{accountAction.accountTypeList}" var="_accountType" label="#{_accountType.title}" noSelectionLabel="SELECT"/> <s:convertEntity> </h:selectOneMenu> </s:decorate>
accountAction:
private List<AccountType> accountTypeList; public List<AccountType> getAccountTypeList() throws Exception { return this.accountTypeList; } public void setAccountTypeList(List<AccountType> accountTypeList) { this.accountTypeList = accountTypeList; }
AccountType:
@Entity @Name("accountType") @Table(name = "accounttype") public class AccountType implements java.io.Serializable { private long id; private String title; private AccountClassification accountClassification; private Set<Account> accounts = new HashSet<Account>(0); private Set<BusinessType> businessTypes = new HashSet<BusinessType>(0); public AccountType() { } public AccountType(String title) { this.title = title; } public AccountType(String title, AccountClassification accountClassification, Set<Account> accounts, Set<BusinessType> businessTypes) { this.title = title; this.accountClassification = accountClassification; this.accounts = accounts; this.businessTypes = businessTypes; } @Id @GeneratedValue @Column(name = "atyp_id_pk", nullable = false) public Long getId() { return this.id; } public void setId(Long id) { this.id = id; } @Column(name = "atyp_title", nullable = false) public String getTitle() { return this.title; } public void setTitle(String title) { this.title = title; } @ManyToOne(fetch = FetchType.EAGER) @Cascade( { CascadeType.LOCK }) @JoinColumn(name = "atyp_accountclassification_id_fk") public AccountClassification getAccountClassification() { return this.accountClassification; } public void setAccountClassification( AccountClassification accountClassification) { this.accountClassification = accountClassification; } @OneToMany(fetch = FetchType.LAZY, mappedBy = "accountType") @Cascade( { CascadeType.ALL, CascadeType.DELETE_ORPHAN, CascadeType.LOCK }) public Set<Account> getAccounts() { return this.accounts; } public void setAccounts(Set<Account> accounts) { this.accounts = accounts; } @ManyToMany(fetch = FetchType.LAZY) @JoinTable(name = "businesstype_accounttype", joinColumns = { @JoinColumn(name = "accounttypeid", updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "businesstypeid", nullable = false, updatable = false) }) @Cascade( { CascadeType.SAVE_UPDATE, CascadeType.LOCK }) public Set<BusinessType> getBusinessTypes() { return this.businessTypes; } public void setBusinessTypes(Set<BusinessType> businessTypes) { this.businessTypes = businessTypes; } }
component.xml:
<?xml version="1.0" encoding="UTF-8"?> <components xmlns="http://jboss.com/products/seam/components" xmlns:core="http://jboss.com/products/seam/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:security="http://jboss.com/products/seam/security" xsi:schemaLocation="http://jboss.com/products/seam/core http://jboss.com/products/seam/core-1.1.xsd http://jboss.com/products/seam/components http://jboss.com/products/seam/components-1.1.xsd http://jboss.com/products/seam/security http://jboss.com/products/seam/security-1.1.xsd"> <core:init debug="true" /> <!-- <core:manager conversation-timeout="120000" /> --> <core:manager conversation-timeout="60000" concurrent-request-timeout="500" conversation-id-parameter="cid" conversation-is-long-running-parameter="clr" /> <security:identity authenticate-method="#{authenticator.authenticate}" /> <event type="org.jboss.seam.notLoggedIn"> <action expression="#{redirect.captureCurrentView}" /> </event> <event type="org.jboss.seam.postAuthenticate"> <action expression="#{redirect.returnToCapturedView}" /> </event> <!-- Bootstrap Hibernate --> <core:hibernate-session-factory /> <core:managed-hibernate-session name="mySession" auto-create="true" /> </components>