[jboss-user] [JBoss Seam] - Losing Home#instance reference
rnallakukkala
do-not-reply at jboss.com
Fri Oct 5 14:35:48 EDT 2007
Hi there,
I'm fairly new the seam world and currently using code base of seam 2 nightly build. was trying to do our business validation and landed into a scenario where my home#instance variable reference is lost upon invocation of an another seam component's method.
here's my code
Home bean
| @Name(MembershipHome.COMPONENT_NAME)
| public class MembershipHome extends EntityHome<Membership> {
|
| @In(value=MembershipValidation.COMPONENT_NAME,create=true)
| private MembershipValidation membershipValidation;
| .....
| .....
| @Override
| public String persist(){
| Membership instance = getInstance();
| membershipValidation.validate();// loosing the reference of the instance variable after this call.
| setInstance(instance);//explicit setting of the instance works as expected, but nasty right?
| if(!membershipValidation.isEmpty()) {
| membershipValidation.flushErrors();
| return "error";//TODO is there any standard form that Seam recommand
| }
| return super.persist();
| }
| .....
| .....
| }
|
Here's my validation class
| @Name(MembershipValidation.COMPONENT_NAME)
| public class MembershipValidation extends BaseValidator{
|
| public final static String COMPONENT_NAME ="membershipValidation";
|
| @In(MembershipHome.COMPONENT_NAME)
| private MembershipHome membershipHome;
|
| public void validate(){
| << some crazy validations>>
| }
| .....
| .....
| }
|
Now the problem I'm running to is
Prior to the "membershipValidation.validate();" method invocation, the home object has the reference to the entity instance, but after the method invocation the "instance" reference is lost.
Please note that explicit setting of the instance reference after this method call (membershipValidation.validate()) works as expected; but explicit setting of the setInstance isnt looking beautiful though :-(.
Can you suggest me what's taking me wrong?
Thanks
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4092125#4092125
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4092125
More information about the jboss-user
mailing list