Validate form field in component class from page class

2012-09-24 Thread George Christman
Hello

I have a component called program that is called from my page template
called purchaseRequest. Within program, I have a field called evaluators and
within the component class I'm @InjectComponent evaluators. I'm trying to do
some field validations on evaluators from within my page validation method.
However I'm not sure how pass the fields around. I tried passing my form
component into my program component and validating using void
onValidateFromEvaluators() however the field value is null even though it's
been populated within the template. Does anybody know how to do this. 

Example

Program.tml
t:TextField t:id=evaluators value=pr.evaluators

Program.class

@Parameter
@Property
private PurchaseRequest pr;

@InjectComponent
@Property
private Field evaluators;


PurcahseRequest.tml

t:Form t:id=PR
t:Program  pr=pr/
/t:Form

PurcahseRequest.class

@Component(id = PR)
@Property
private Form form;   

Object onValidateFromPr() {

for(PrEvaluator evaluator : this.pr.getPrEvaluators()) {
if (evaluator.getEvaluator() != null) {
if(evaluatorUsers.contains(evaluator.getEvaluator())) {

//I can not set this.evaluators field because it's not
contained within the page.
this.form.recordError(this.evaluators, Evaluator(s)
must be unique.);
} 
}
}
}



--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Validate-form-field-in-component-class-from-page-class-tp5716469.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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



Re: Validate form field in component class from page class

2012-09-24 Thread Thiago H de Paula Figueiredo
On Mon, 24 Sep 2012 14:29:02 -0300, George Christman  
gchrist...@cardaddy.com wrote:



Hi Thiago, I'm not completely following you here. What do you mean by
trigger an event passing to the page?


Something like this (not tested):

@Inject
private ComponentResources resources;

...

resources.triggerEvent(validate, valueToBeValidated, null);


I have all the in formation in the
PurchaseRequest class to do the validation, just no way to mark the field
as having an error with the red border.


So pass the Field itself in the second parameter of triggerEvent().

--
Thiago H. de Paula Figueiredo

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