Hi,

Our application has a page which submits a form through a submit button and
it goes through the page 'onValidate' and fails the validation.

the .tml file has

<tc:groupbox>
            <table>
               - - - - - -
               - - - - -
               <td valign="center"><tc:genbutton><input t:type="submit"
t:id="submit" t:mixins="common/blockingClick"
value="${message:button.save}"/></tc:genbutton></td>

             <td valign="center"><tc:genbutton><a t:type="actionLink"
t:id="cancel"
t:mixins="common/blockingClick">${message:button.cancel}</a></tc:genbutton></td>

- - - - - - - - -
- - - - - - - -

                        <t:label for="name"><font
size="+0"><b>${message:name-label}</b> * </font></t:label>

                    <td>
                        <t:textfield t:id="name" value="theZone.name"
t:validate="maxlength=50"/>
                    </td>


In our page file:

@Property
//    @Persist(PersistenceConstants.FLASH)  --- I tested with this also.
doesn't work.
    private TaxZone theZone;


- - - - - -
- - - - - -

void onActivate(final Long aRowId) throws SQLException {

        if (theZone == null) {
            if (rowid == null || rowid == -1L) {
                theZone = new TaxZone("");
            }else{
 // get from db
}
- - - - -
- - - - - -

void onValidate() {
            if (theZone.getName() == null || *theZone.getName().trim().length()
== 0*) {
                form.recordError(nameField, "You must enter a name.");
            }
        }

Even if we put a value into the text filed it comes back to the page after
validation and shows 'You must enter a name' message.

I have bebugged through the code and it seems that after submitting the
form with a value entered into the name field the flow goes through the
'onActivate' and creates an empty 'theZone' and then gets validated which
creates the error message. After that only the flow populates 'theZone'
with the value I had entered and gets validated again through the
'onValidate' method for the second time and get passed. But since it
already has an error message in it's first 'onValidate' call it comes back
to the page and shows the error message.

I have tried with removing the code block from 'onActivate' and putting
that into the 'setupRender' and in this case the flow throws a
'NullPointerException' in 'onValidate' since it couldn't find an instance
of 'theZone'.

Also tried with @Persist for the 'theZone' property. That didn't work.

It seems after the form submit with a value 'theZone' doesn't get
initialized with the entered value. And if it's already initialized through
the 'onActivate' code it doesn't get populated with the entered name before
the 'onValidate' call.

This code used to work in our old Tapestry 5.1.0.5. We are upgrading to
version 5.4.0

I wonder if this is related to javascript update in new Tapestry framework
or I am missing something to make it work.

I would appreciate any response.

Thanks a lot.

Reply via email to