Sorry I messed up the code example corrected version: public class Persion { ... @Id @GeneratedValue(strategy = GenerationType.AUTO) @NonVisual //<-- that excludes this member from the generated // BeanModel. This could also be done manually whit "exclude". // (see BeanModel for further information. public Person getId() { return person; } ... }
nillehammer schrieb: > With BeanEditForm Person need not be instanciated in onActivate. That is > done "automagically" by the component itself. > > The Exception surely refers to the id. Id being the only number in your > Person class. Although I do not know, why that would be a problem for > Tapestry, you surely would not want the user to edit the database id. So > try the following. You might get rid of your problem with that: > public class Persion { > ... > @NonVisual //<-- that excludes this member from the generated > // BeanModel. This could also be done manually whit "exclude". > // (see BeanModel for further information. > public Person getPerson() { > return person; > } > ... > } > > > > Otho schrieb: >> You obviously left out some things for brevity, but I can't see "Person" >> anywhere instantiated? >> >> public class PersonForm { >> >> @Persist >> @Property //no need for accessors >> private Person person; >> >> Object onActivate() >> { >> if(person==null) >> person = new Person(); >> >> return null; >> } >> >> Object onSuccessFromPersonEditor() >> { >> .... >> .... >> return null; >> } >> } >> >> And you also seem to not have an id for the beaneditform. with the above >> code that would be: >> >> <t:beaneditform t:id="personEditor" t:object="person"/> >> >> Regards, >> Otho >> >> 2008/12/11 mraible <m...@raibledesigns.com> >> >>> I'm working on a simple CRUD example for Tapestry 5 (version 5.0.18) today >>> in >>> order to create the necessary FreeMarker templates for AppFuse's Maven >>> Plugin. Here's my form class: >>> >>> package org.appfuse.webapp.pages; >>> >>> import org.apache.tapestry5.annotations.Persist; >>> import org.apache.tapestry5.annotations.Property; >>> import org.apache.tapestry5.ioc.annotations.Inject; >>> import org.appfuse.model.Person; >>> >>> public class PersonForm { >>> >>> @Persist >>> private Person person; >>> >>> public Person getPerson() { >>> return person; >>> } >>> >>> public void setPerson(Person person) { >>> this.person = person; >>> } >>> } >>> >>> My PersonForm.tml: >>> >>> <t:layout title="message:personForm.title" >>> heading="message:personForm.heading" menu="literal:PersonMenu" >>> xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd"> >>> <body> >>> <h1>Create New Person</h1> >>> >>> <t:beaneditform t:object="person"/> >>> </body> >>> </t:layout> >>> >>> Pretty simple. The Person.java object is as follows: >>> >>> package org.appfuse.model; >>> >>> import javax.persistence.*; >>> >>> @Entity >>> public class Person { >>> private Long id; >>> private String firstName; >>> >>> public void setFirstName(String firstName) { >>> this.firstName = firstName; >>> } >>> >>> public void setId(Long id) { >>> this.id = id; >>> } >>> >>> public void setLastName(String lastName) { >>> this.lastName = lastName; >>> } >>> >>> private String lastName; >>> >>> @Id >>> @GeneratedValue(strategy = GenerationType.AUTO) >>> public Long getId() { >>> return this.id; >>> } >>> >>> @Column(name = "first_name", length = 50) >>> public String getFirstName() { >>> return this.firstName; >>> } >>> >>> @Column(name = "last_name", length = 50) >>> public String getLastName() { >>> return this.lastName; >>> } >>> >>> public String toString() { >>> return firstName + ' ' + lastName; >>> } >>> } >>> >>> When I access http://localhost:8080/personform, I get >>> the following error: >>> >>> Render queue error in >>> AfterRender[PersonForm:beaneditform.editor.loop]: Failure reading >>> parameter 'validate' of component core/PropertyEditBlocks:numberfield: >>> No object of type org.apache.tapestry5.services.PropertyEditContext is >>> available from the Environment. Available types are >>> org.apache.tapestry5.RenderSupport, >>> org.apache.tapestry5.ValidationDecorator, >>> org.apache.tapestry5.ValidationTracker, >>> org.apache.tapestry5.internal.services.ClientBehaviorSupport, >>> org.apache.tapestry5.internal.services.DocumentLinker, >>> org.apache.tapestry5.services.BeanEditContext, >>> org.apache.tapestry5.services.FormSupport, >>> org.apache.tapestry5.services.Heartbeat. >>> >>> Any ideas? >>> >>> Thanks, >>> >>> Matt >>> -- >>> View this message in context: >>> http://www.nabble.com/BeanEditForm-Component-in-Tapestry-5-tp20964358p20964358.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 >>> >>> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org