[
https://issues.apache.org/jira/browse/TAPESTRY-1972?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12572463#action_12572463
]
Geoff Callender commented on TAPESTRY-1972:
-------------------------------------------
I'm tending to agree.
An alternative that works - ie. that allows onSuccess() to return null,
redisplaying the page with errors AND WITHOUT undoing your input - is to use
@Persist("flash") on the object or fields of the page. For tidiness you might
also nullify them in cleanupRender(). However, that alternative seems clunky
and less-than-obvious to the maintenance programmer who will follow.
In the meantime I confess I'm growing used to putting everything that could
create error messages into onValidate(). The following actually reads quite
sanely!
void onValidateForm()
{
if (!_authenticator.isValid(_userName, _password))
{
_form.recordError(_passwordField, "Invalid user name or
password.");
}
}
String onSuccess()
{
return "PostLogin";
}
> Client persistence bug - user typing lost
> -----------------------------------------
>
> Key: TAPESTRY-1972
> URL: https://issues.apache.org/jira/browse/TAPESTRY-1972
> Project: Tapestry
> Issue Type: Bug
> Components: tapestry-core
> Affects Versions: 5.0.6
> Environment: Safari, OS X, JBoss 4.2.1
> Reporter: Geoff Callender
>
> The user loses the changes they typed into an "input" or "edit" page if an
> error is recorded by onSuccess() AND the page is dealing with a client
> persisted object. The page is redisplayed OK, with error, but with the
> previous values!!!
> The user's changes aren't lost if
> (a) I move the work that finds the error from onSuccess() into onValidate() -
> this fixes all TextField components but does not fix Select, DateField,
> checkbox, or expansions; or
> (b) I add a simple client-persisted field to the page - remarkably this
> fixes; or
> (c) I replace client persistence with session persistence.
> To illustrate the problem, it's just like the example from
> http://tapestry.apache.org/tapestry5/tapestry-core/guide/validation.html,
> which contains these excerpts:
> @Persist
> private String _userName;
> private String _password;
> String onSuccess()
> {
> if (!_authenticator.isValid(_userName, _password))
> {
> _form.recordError(_passwordField, "Invalid user name or
> password.");
> return null;
> }
> return "PostLogin";
> }
> except that instead of a single field, _userName, I am persisting a whole
> object, _user:
> @Persist("client")
> private User _user;
> and in the template we refer to its fields, eg:
> <input t:type="TextField" t:id="firstName"
> value="user.firstName" ...
> If the user types a value into firstName, but the onSuccess() method records
> an error, then the user loses what they typed.
> However, if I add another field to the page then everything works!
> @Persist("client")
> private String _aField;
> <input t:type="TextField" t:id="aField" value="aField" ...
> Alternatively, it works if I do either of the other 2 things - use session
> persistence or move all logic into onValidate().
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]