Problem injecting form component for onValidateForm()

View: New views
2 Messages — Rating Filter:   Alert me  

Problem injecting form component for onValidateForm()

by richp123 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am attempting to do cross-field form validation with the onValidateForm() method.  In order to access the form, I have included the following in my page class:

@Component
private Form templateForm;

This should give me access to the form object so I can call recordError(...).

As straightforward as this may seem, whenever I uncomment the two lines of code above, my page begins to behave very strangely.  When I submit the form, instead of showing my page (http://localhost:8080/DefineTemplate), it instead trys to render the following:

http://localhost:8080/definetemplate.form

This results in a 404 error.  The onValidateForm() method is never called.  At this point, I assume the problem must be in my .tml file, but I am at a loss.  I'm relatively new to Tapestry, so I apologize if the answer is obvious!!  Thanks in advance for any help.  

The basic form is shown below:



        <t:form id="templateForm">

            <t:errors/>

            <table t:id="grid" t:type="Grid" source="pricingTemplateDrivers" row="item" exclude="pricingTemplateDriverId" reorder="labelText,pricingTemplateDriverEnum,driverValue,driverMinValue,driverMaxValue">
                    <p:pricingTemplateDriverEnumCell>
                    <t:select t:id="pricingTemplateDriverEnum" value="item.pricingTemplateDriverEnum"/>
                    </p:pricingTemplateDriverEnumCell>
                   
                    <p:driverValueCell>
                    <t:textfield t:id="driverValueCell" value="item.driverValue"/>
                    </p:driverValueCell>
                   
                    <p:driverMinValueCell>
                    <t:textfield t:id="driverMinValueCell" value="item.driverMinValue"/>
                    </p:driverMinValueCell>
                   
                    <p:driverMaxValueCell>
                    <t:textfield t:id="driverMaxValueCell" value="item.driverMaxValue"/>
                    </p:driverMaxValueCell>
           
            </table>

            <input type="submit" value="Update Items"/>

        </t:form>



Re: Problem injecting form component for onValidateForm()

by Ville Virtanen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

One thing to remember is that @Component annotation DEFINES new component, where as @InjectComponent would inject the component defined in .tml: perhaps this has something to do with that?

Anyway, a bit more of the code / logic would make it easier to speculate.

 - Ville

richp123 wrote:
I am attempting to do cross-field form validation with the onValidateForm() method.  In order to access the form, I have included the following in my page class:

@Component
private Form templateForm;

This should give me access to the form object so I can call recordError(...).

As straightforward as this may seem, whenever I uncomment the two lines of code above, my page begins to behave very strangely.  When I submit the form, instead of showing my page (http://localhost:8080/DefineTemplate), it instead trys to render the following:

http://localhost:8080/definetemplate.form

This results in a 404 error.  The onValidateForm() method is never called.  At this point, I assume the problem must be in my .tml file, but I am at a loss.  I'm relatively new to Tapestry, so I apologize if the answer is obvious!!  Thanks in advance for any help.  

The basic form is shown below:



        <t:form id="templateForm">

            <t:errors/>

            <table t:id="grid" t:type="Grid" source="pricingTemplateDrivers" row="item" exclude="pricingTemplateDriverId" reorder="labelText,pricingTemplateDriverEnum,driverValue,driverMinValue,driverMaxValue">
                    <p:pricingTemplateDriverEnumCell>
                    <t:select t:id="pricingTemplateDriverEnum" value="item.pricingTemplateDriverEnum"/>
                    </p:pricingTemplateDriverEnumCell>
                   
                    <p:driverValueCell>
                    <t:textfield t:id="driverValueCell" value="item.driverValue"/>
                    </p:driverValueCell>
                   
                    <p:driverMinValueCell>
                    <t:textfield t:id="driverMinValueCell" value="item.driverMinValue"/>
                    </p:driverMinValueCell>
                   
                    <p:driverMaxValueCell>
                    <t:textfield t:id="driverMaxValueCell" value="item.driverMaxValue"/>
                    </p:driverMaxValueCell>
           
            </table>

            <input type="submit" value="Update Items"/>

        </t:form>