You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by George Christman <gc...@cardaddy.com> on 2013/03/21 16:33:46 UTC

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

Re: InjectComponent Field in component and validate field in page class

Posted by Ivan Khalopik <ik...@gmail.com>.
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 <ma...@yahoo.com> wrote:
> The following example might be useful.
>
>
>
> http://lombok.demon.co.uk/tapestry5Demo/test/crossvalidation2
>
>
>
> Shing
>
>
> ----- Original Message -----
> From: George Christman <gc...@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-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>



-- 
BR
Ivan

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


Re: InjectComponent Field in component and validate field in page class

Posted by Shing Hing Man <ma...@yahoo.com>.
The following example might be useful.



http://lombok.demon.co.uk/tapestry5Demo/test/crossvalidation2

 

Shing 


----- Original Message -----
From: George Christman <gc...@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-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org