You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by "Vjeran Marcinko (JIRA)" <de...@tapestry.apache.org> on 2008/07/07 13:13:31 UTC

[jira] Commented: (TAPESTRY-1972) Client persistence bug - user typing lost

    [ https://issues.apache.org/jira/browse/TAPESTRY-1972?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12611061#action_12611061 ] 

Vjeran Marcinko commented on TAPESTRY-1972:
-------------------------------------------

Is there some special reasons why ValidationTracker input values have to be cleared after success event (or any other)?

My experience is that in large majority of cases, whenever someone stays on the same form page after submit, regardless whether it was error or not, I want  to see all those input values still there.
And it all works except when error are caught in onSuccess

And I think people forget that some actions throw checked exceptions. 
Example is saving user:

UserDao.save(User user) throws UsernameReservedException;

I think most of the people would assume to call this final action after all possible fields have been validated, but there is no way one can find out if "username" has been reserved without calling service layer action beforehand.  Normal place to call this action would be in onSuccess method. And error still have to be caught and displayed in case of exception thrown (I hope none will seriously suggest that right aproach would be to separate checking of username in separate service layer action to be called in onValidate).

Other cases when input should be kept is when I display search result table on same page where search form is. This way it is great to keep all those values presented to člet user know what search criteria have been.

Maybe in some rare cases one would want to stay on same page and clear Validationtracker input values, but then he could call explicitly validationTracker.clear() or whatever. 
I agree that this whole problem can possibly be overcome by persisting form model instance, but that is neither the simpliest nor righteouss aproach IMO.

Thoughts?


> 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
>            Assignee: Howard M. Lewis Ship
>
> 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: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org