Re: Validate form field in component class from page class
On Mon, 24 Sep 2012 14:29:02 -0300, George Christman 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
Validate form field in component class from page class
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 Program.class @Parameter @Property private PurchaseRequest pr; @InjectComponent @Property private Field evaluators; PurcahseRequest.tml 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