[ 
https://issues.apache.org/jira/browse/TAP5-1919?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Geoff Callender updated TAP5-1919:
----------------------------------

    Description: 
Since Hidden is not tracked by the Validation Tracker, its value is lost when a 
page redirects to display validation errors. I'd like to see a new component, 
say Tracked. I guess it would be the same as Hidden and extend 
AbstractTextField or similar.

Why? A common use case is to use Hidden for an entity's version field in a Form 
to provide optimistic locking. By using Tracked instead of Hidden I could do 
this...

    <form t:type="Form" t:id="person" >
        <t:tracked value="person.version"/>
        :
    </form>

...instead of this...

    <form t:type="Form" t:id="person" >
         <t:hidden value="person.version"/>
        :
    </form>

    // This carries version through the redirect that follows a server-side 
validation failure.
    @Persist(PersistenceConstants.FLASH)
    private Integer versionFlash;

    void onPrepareForRender() throws Exception {
        person = findPerson(personId);

        // If the form has errors then we're redisplaying after a redirect.
        // Form will restore your input values but it's up to us to restore 
Hidden values.

        if (form.getHasErrors()) {
            person.setVersion(versionFlash);
        }
    }
        
    void onFailure() {
        versionFlash = person.getVersion();
    }

Thoughts?

Geoff


  was:
Since Hidden is not tracked by the Validation Tracker, its value is lost when a 
page redirects to display validation errors. I'd like to see a new component, 
say Tracked. I guess it would be the same as Hidden and extend 
AbstractTextField or similar.

Why? A common use case is to use Hidden for an entity's version field in a Form 
to provide optimistic locking. By using Tracked instead of Hidden I could do 
this...

        <form t:type="Form" t:id="person" >
                <t:tracked value="person.version"/>
                :
        </form>

...instead of this...

        <form t:type="Form" t:id="person" >
                <t:hidden value="person.version"/>
                :
        </form>

        // This carries version through the redirect that follows a server-side 
validation failure.
        @Persist(PersistenceConstants.FLASH)
        private Integer versionFlash;

        void onPrepareForRender() throws Exception {
                person = findPerson(personId);

                // If the form has errors then we're redisplaying after a 
redirect.
                // Form will restore your input values but it's up to us to 
restore Hidden values.

                if (form.getHasErrors()) {
                        person.setVersion(versionFlash);
                }
        }
        
        void onFailure() {
                versionFlash = person.getVersion();
        }

Thoughts?

Geoff


    
> A Hidden that is also tracked by Validation Tracker
> ---------------------------------------------------
>
>                 Key: TAP5-1919
>                 URL: https://issues.apache.org/jira/browse/TAP5-1919
>             Project: Tapestry 5
>          Issue Type: Improvement
>          Components: tapestry-core
>    Affects Versions: 5.3
>            Reporter: Geoff Callender
>
> Since Hidden is not tracked by the Validation Tracker, its value is lost when 
> a page redirects to display validation errors. I'd like to see a new 
> component, say Tracked. I guess it would be the same as Hidden and extend 
> AbstractTextField or similar.
> Why? A common use case is to use Hidden for an entity's version field in a 
> Form to provide optimistic locking. By using Tracked instead of Hidden I 
> could do this...
>     <form t:type="Form" t:id="person" >
>         <t:tracked value="person.version"/>
>         :
>     </form>
> ...instead of this...
>     <form t:type="Form" t:id="person" >
>          <t:hidden value="person.version"/>
>         :
>     </form>
>     // This carries version through the redirect that follows a server-side 
> validation failure.
>     @Persist(PersistenceConstants.FLASH)
>     private Integer versionFlash;
>     void onPrepareForRender() throws Exception {
>         person = findPerson(personId);
>         // If the form has errors then we're redisplaying after a redirect.
>         // Form will restore your input values but it's up to us to restore 
> Hidden values.
>         if (form.getHasErrors()) {
>             person.setVersion(versionFlash);
>         }
>     }
>       
>     void onFailure() {
>         versionFlash = person.getVersion();
>     }
> Thoughts?
> Geoff

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to