Hi Andy,
maybe I'm leaning to much out of the window because I have not enough
Hibernate knowledge, but I don't think Hibernate stores its sessions in
the entities - more like vice versa storing references to the entities
in the session. (Don't count to much on my word - like I said, it's just
an assumption.)
Well, at least I can say for sure: I'm using @Persist on my hibernate
entities and it never caused a problem.
Tobias
Andy Huhn schrieb:
Hello,
I have a page that uses a BeanEditForm to allow the user to edit a bean.
I'm using the @Validate annotation on various fields in the bean to mark
them as required, or to assign a minimum length, etc.
My problem is that if the validation fails and the page redisplays, all
of the user's changes are lost. I thought about using @Persist to
persist the bean (_orgnztn in the class below), but won't that cause
issues, since this is a Hibernate entity? Won't that cause a reference
to the Session to be persisted also, so that the next time this page is
loaded, it may use the wrong Session?
My page class is something like this:
public class EditOrganization {
@Component
private BeanEditForm _orgnztnEditForm;
@Persist( "flash" )
private Integer _orgnztnId;
private Organization _orgnztn;
public Object onActivate( Integer prmOrgnztnId ) {
setOrgnztnId( prmOrgnztnId );
return( null );
}
public Object onActivate() {
if( getOrgnztnId() != null ) {
setOrgnztn( <snip>get from DAO</snip> );
}
return( unathrzdRdrct() );
}
public Object onPassivate() {
return( getOrgnztnId() );
}
public Object onSuccess() {
Organization thisOrgnztn = getOrgnztn();
<snip>Use Hibernate to update the
Organization record in the DB</snip>
return( <snip>a page class</snip> );
}
public Organization getOrgnztn() {
return _orgnztn;
}
public void setOrgnztn(Organization prmOrgnztn ) {
_orgnztn = prmOrgnztn;
}
public Integer getOrgnztnId() {
return _orgnztnId;
}
public void setOrgnztnId( Integer prmOrgnztnId ) {
_orgnztnId = prmOrgnztnId;
}
}
And my template is similar to this:
<t:layout
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd" >
<t:beaneditform object="orgnztn" t:id="orgnztnEditForm">
</t:beaneditform>
</t:layout>
Thanks,
Andy
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]