The basic problem: one page's listener calls another page's listener
(after activating the other page). The other page records a
validation error, and that causes a NullPointerException deep in
Tapestry's guts.
The details:
I have two pages (Subscribe and SubscribeAlternateLink), both of
which involve the user entering/selecting a URL. Once the URL is
entered, they share the same logic -- and I want either one of them
to end up on the Subscribe page in case of an error.
So I have this page delegate its subscribe() listener to the other page:
public abstract class SubscribeAlternateLink extends MyBasePage {
...
public IPage subscribe(String url) {
Subscribe subscribePage = getPage(Subscribe.class);
subscribePage.setUrl(url);
getRequestCycle().activate(subscribePage);
return subscribePage.subscribe();
}
...
}
And the other page has a URL field, which will show the URL the user
entered, with an error:
public abstract class Subscribe
extends MyBasePage {
@Bean( value=ReaderValidation.class )
public abstract IValidationDelegate getFormValidation();
@Component(type="TextField", bindings = {
"value=ognl:url",
"validators=validators:required" } )
public abstract TextField getUrlField();
public abstract String getUrl();
public abstract void setUrl(String url);
public IPage subscribe() {
if(getFormValidation().getHasErrors())
return this;
try {
// ... do subscription ...
} catch(SubscriptionException e) {
getFormValidation().record(getUrlField(),
e.getMessage()); // ***
return this;
}
// ... follow-up stuff ...
}
}
When submitting from the Subscribe page, errors get recorded fine.
When submitting from the SubscribeAlternateLink, I get an exception
on the line marked ***:
java.lang.NullPointerException: Parameter fieldName must not be
null.
• org.apache.hivemind.util.Defense.notNull(Defense.java:41)
• org.apache.tapestry.valid.FieldTracking.<init>(FieldTracking.java:59)
• org.apache.tapestry.valid.ValidationDelegate.findCurrentTracking
(ValidationDelegate.java:279)
• org.apache.tapestry.valid.ValidationDelegate.record
(ValidationDelegate.java:225)
• org.apache.tapestry.valid.ValidationDelegate.record
(ValidationDelegate.java:207)
• org.apache.tapestry.valid.ValidationDelegate.record
(ValidationDelegate.java:240)
• com.dci.cyclonereader.web.Subscribe.subscribe(Subscribe.java:41)
• com.dci.cyclonereader.web.SubscribeAlternateLink.subscribe
(SubscribeAlternateLink.java:28)
It looks like the URL component on the Subscribe page isn't fully
initialized. Is this a bug? Or do I need to do something more to
initialize the Subscribe page?
Cheers,
Paul
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]