I'm having a similar problem and modifying the setter doesn't work for me.
In my use case, i have a Double property in a page. This property is
bound to the value of a TextField. If i submit with the textfield an
empty a "0.0" value shows up, instead of the submitted value that was null.
I've tracked the problem down to the TypeCoercer implementation. The
given implementation coerces null values into the default value of a
type. So if you want to coerce a null to a Double if return 0.0d instead
of just null.
I'm not sure if this is actually intended behavior and there's probably
an easy way through configuration or something to solve my use case or
if it's a bug.
Anyone ?
Angelo Chen wrote:
Hi Nick,
Using a setter does work, right?
Nick Westgate wrote:
Getters/setters are only required for JavaBean conformity, e.g. to use
prop.
I've just tested this on 5.0.5 (maybe 5.0.6 later if I get time) ...
There is a bug - setting the property to null doesn't work.
If someone can verify this on 5.0.6 before I do, please log a JIRA.
Cheers,
Nick.
Josh Canfield wrote:
if I have an attribute, I should use a setter to assign it? like this:
Hmm... looking at javassist, it looks like there is the ability to modify
field level access within a method. Perhaps, if changing to the setter
worked then this should be filed as a defect, if it isn't already.
Josh
On 10/11/07, Angelo Chen <[EMAIL PROTECTED]> wrote:
Hi,
You are correct. this does bring up a question:
if I have an attribute, I should use a setter to assign it? like this:
private String id;
void onActivate() {
id = "myid"; // wrong
setId("myid"); // correct ?
if (id == "myid"); // wrong
if (getId() == "myid"); // correct?
}
?
Josh Canfield-2 wrote:
even i set uid to null, it is still not null next time when the page
is
activated, why? what's the correct way of setting a persisted variable
null?
I would guess that the right way to do it would be to use the setter
method
for the attribute. I haven't looked, but I would guess that Tapestry is
catching assignments to that attribute via the setter, and when you set
it
directly you are bypassing that code.
Josh
On 10/11/07, Angelo Chen <[EMAIL PROTECTED]> wrote:
Hi,
I have this class:
public class Confirmation {
@Persist
private String uid;
public Class onActivate(String id) {
if (uid == null) {
uid = id;
}
return null;
}
public String onPassivate() { return uid;}
String onActionFromAutoLogin() {
uid = null;
return "MyPage";
}
}
even i set uid to null, it is still not null next time when the page
is
activated, why? what's the correct way of setting a persisted variable
null?
Thanks.
A.C.
--
View this message in context:
http://www.nabble.com/T5%3A-How-to-set-persisted-variable-to-null-tf4605726.html#a13151324
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
--
TheDailyTube.com. Sign up and get the best new videos on the internet
delivered fresh to your inbox.
--
View this message in context:
http://www.nabble.com/T5%3A-How-to-set-persisted-variable-to-null-tf4605726.html#a13166676
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]