You can add getter for injected field inside vendor component:

Vendor.class

@InjectComponent
private Field vendorNameField;

public Field getVendorNameField() {
   return vendorNameField;
}

Then inject vendor component inside the page

Page.class

@InjectComponent
private Vendor vendor;

void onValidateFromForm()  {
    if(condition == true) {
        form.recordError(vendor.getVendorNameField(), "some error message");
    }
}

Don't forget to use t:id attributes on injected components.


On Thu, Mar 21, 2013 at 6:43 PM, Shing Hing Man <mat...@yahoo.com> wrote:
> The following example might be useful.
>
>
>
> http://lombok.demon.co.uk/tapestry5Demo/test/crossvalidation2
>
>
>
> Shing
>
>
> ----- Original Message -----
> From: George Christman <gchrist...@cardaddy.com>
> To: users@tapestry.apache.org
> Cc:
> Sent: Thursday, March 21, 2013 3:33 PM
> Subject: InjectComponent Field in component and validate field in page class
>
> I have a component that contains a field like so,
>
> Vendor.class
>
> @InjectComponent
> @Parameter
> private Field vendorName;
>
> I have a page class like so,
>
> Page.class
>
> @Property
> private Field vendorName;
>
> onValidateFromForm() {
>
> //I would like to do some serverside validation and return the error back
> to the field, but I'm not sure how to connect the field in the component
> with the page class.
>
>     if(condition == true) {
>         form.recordError(vendorName, "some error message");
>     }
>
> }
>
> Page.tml
>
> <t:vendor vendorName="vendorName"/>
>
> Anybody know if it's possible to connect the fields like this. Thanks
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>



-- 
BR
Ivan

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to