This topic comes up periodically.  Under T4, it might come up under
null-handlers for OGNL where a usr object could automatically be created if
one did not exist already.

One way or another, you need to make sure that usr is not null when you go
to assign the name.

It's OK for name to be null in Edit1, and usr.name to be null in Edit2, but
you can't have usr be null in Edit2.

That's half the answer anyway.  The other half must be in the behavior of
@Persist, or in code that you have not included.


> -----Original Message-----
> From: Angelo Chen [mailto:[EMAIL PROTECTED]
> Sent: Monday, October 22, 2007 4:15 AM
> To: [email protected]
> Subject: T5: @Persist form field or not?
> 
> 
> Hi,
> 
> I have two classes, Edit1 and Edit2,  name is the form field, when I
> submit
> the form using Edit1, everything works, and when I tried Edit2, it
> generates
> an exception:
> 
> java.lang.NullPointerException
> Stack trace
>       .       org.bfe.test.t5.pages.Edit.setName(Edit.java:52)
>       .
> org.apache.tapestry.internal.bindings.PropBinding.set(PropBinding.java:67)
> 
> What's the difference here? if I @Persist usr, error goes away, then why I
> don't have @Persist name in the Edit1's case? thanks.
> 
> A.C.
> 
> 
> public class Edit1 {
>     private String name;
> 
>     public String getName() {
>         return name;
>     }
> 
>     public void setName(String name) {
>         this.name;
>     }
> 
> public class Edit2 {
>     private Usr usr;
> 
>     public String getName() {
>         return usr.getName();
>     }
> 
>     public void setName(String name) {
>         this.usr.setName(name);
>     }
> 
> 
> --
> View this message in context: http://www.nabble.com/T5%3A-%40Persist-form-
> field-or-not--tf4669367.html#a13338569
> Sent from the Tapestry - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> 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]

Reply via email to