>From the javadoc for SelectModelFactory... (
http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/SelectModelFactory.html
)

 "The returned model creates for every object in the list a selectable
option and relies on existing
ValueEncoder<http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ValueEncoder.html>
for
the object type."

So, you need to contribute a ValueEncoder for your WholeSaleMember.

I believe that the tapestry-hibernate module does that automatically for
Hibernate entities, but since you are using Spring, you would need to do it
on your own.



On Tue, Sep 20, 2011 at 10:57 PM, csckid <testnowsh...@gmail.com> wrote:

> Select component is populated. But I wasn't able to fetch the id variable
> of
> the selected object.
> *CreateWMemberTruck.tml *
> <form t:type="form">
>   <t:label for="members"/>:
>    <t:select t:id="members" value="membersName" model="MemberSelectModel"
> />
>    <t:submit value="save"/>
>  </form>
>
> *CreateWMemberTruck.java *
>
> public class CreateWMemberTruck {
>
>
>        @Inject
>        private WholeSaleMemberDao wholeSaleMemberDao;
>
>        @Property
>        private SelectModel memberSelectModel;
>        @Property
>        @Inject
>        private SelectModelFactory selectModelFactory;
>
>        @Property
>        private WholeSaleMember membersName;
>
>
>        void setupRender() {
>
>            List<WholeSaleMember> members =
> wholeSaleMemberDao.getWholeSaleMembers();
>
>
>            memberSelectModel = selectModelFactory.create(members, "fName");
>        }
>
>        void onSuccess() {
>
>                System.out.println("\n\n\n"+
> membersName.getId()+"\n\n\n\n");
>
>        }
> }
>
>  When I click on submit it says. I thought I will be able to call
> membersName.getId()
> *Exception*
> org.apache.tapestry5.ioc.internal.OperationException
> "Could not find a coercion from type java.lang.String to type
> com.kids.crm.db.WholeSaleMember."
> #
>
> location
>    classpath:com/kids/crm/pages/wholesalemember/CreateWMemberTruck.tml,
> line 5
>    1   <html t:type="layout" title="Create Whole sale Member Truck"
>    2   t:sidebarTitle="Browse Wood"
>    3   xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd";
>    4   xmlns:p="tapestry:parameter">
>    5   <form t:type="form">
>    6   <t:label for="truckid"/>:
>    7   <t:textfield t:id="truckid" validate="required" value="tbxValue"/>
>    8   <t:label for="members"/>:
>    9   <t:select t:id="members" value="membersName"
> model="MemberSelectModel"
> />
>    10  <t:submit value="save"/>
> trace
>
>        * Triggering event 'action' on
> wholesalemember/CreateWMemberTruck:form
>
> # org.apache.tapestry5.runtime.ComponentEventException
> Could not find a coercion from type java.lang.String to type
> com.kids.crm.db.WholeSaleMember.
>
>
> *WholeSaleMember.java *
> @Entity
> @Table(name = "whole_sale_member")
> public class WholeSaleMember {
>        private Long id;
>        private String fName;
>        private String lName;
>        private String cellNumber;
>        private String officePhoneNumber;
>        private String address;
>        private TruckWoodPrice truckWoodPrice;
>        private Date created;
>        private Date updated;
> ..getters and setters
> }
>
> *WholeSaleMemberDaoImpl .java*
> @Service("wholeSaleMemberDao")
> @Transactional
> public class WholeSaleMemberDaoImpl extends HibernateDaoSupport implements
> WholeSaleMemberDao{
>        public ArrayList getWholeSaleMembers() {
>                return (ArrayList) getHibernateTemplate().find("from
> WholeSaleMember");
>        }
> }
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/tapestry-select-model-tp4823674p4824898.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


-- 
Jonathan Barker
ITStrategic

Reply via email to