Hello, I it sort of working(code is below). My 2 problems are this:
1:If I put 2 components in the page editing the 2nd, edits the first and I assume it is because it is always running the first form/zone as the names of the second ones have _0 after it. I do not know how to get around this. 2:I still cannot figure out how to bubble the event to the page so I can use the value on submit(IE save the object the field is a member of) <div xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd"> <div t:type="Zone" t:id="zone" > <form t:type="form" t:zone="zone" t:id="form"> <div t:type="Errors"/> ${value} <t:ButtonFragment t:id="buttonfragment" t:mixins="triggerfragment" fragment="formfragment"/> <t:formfragment t:id="formfragment" visible="buttonfragment" > <input t:type="TextField" t:id="value" t:validate="required"/> <input type="submit" value="Save"/> </t:formfragment> </form> </div> </div> public class AjaxEditor { @InjectComponent private Zone zone; @Parameter @Property private String _value; @Property private boolean _buttonfragment; @Component(id = "value") private TextField _valueField; @Component(id = "form") private Form _form; @OnEvent(value = EventConstants.VALIDATE_FORM, component="form") public Object validate() { if (_value == null ||_value.trim().equals("")) { //validation errors _form.recordError("must have a fname"); return zone; } else { return null; // let the form submission process continue } } @OnEvent(value = EventConstants.SUCCESS, component="form") public Object sucess() { // do whatever you want _buttonfragment = false; return zone; } } Thanks, --James -----Original Message----- From: James Sherwood [mailto:[email protected]] Sent: January-24-09 9:13 PM To: 'Tapestry users' Subject: Advanced Component help Hello, I am looking for a good tutorial(or help) on advanced components with forms and event bubbling. In particular a component that takes a value(with some paramaters) then spits out a form with a form fragment inside a zone. When the user clicks a button in this component the value parameter is to be changed and an OnEvent caught to manipulate it. I am not even sure if this is. Below is the code I would like to turn into a single value component(it is basically an in place editor): <div t:type="Zone" t:id="firstNameZone" > <form t:type="form" t:zone="firstNameZone" t:id="firstNameForm"> <div t:type="Errors"/> ${firstName} <t:ButtonFragment t:id="modifyFirstName" t:mixins="triggerfragment" fragment="firstNameModify"/> <t:formfragment t:id="firstNameModify" visible="modifyFirstName" > <input t:type="TextField" t:id="firstName" t:validate="required"/> <input type="submit" value="Save"/> </t:formfragment> </form> </div> @InjectComponent private Zone firstNameZone; @Property private String _firstName = "Fname"; @Property private boolean _modifyFirstName; @Component(id = "firstName") private TextField _firstnameField; @Component(id = "firstNameForm") private Form _firstNameForm; @OnEvent(value = EventConstants.VALIDATE_FORM, component="firstNameForm") public Object validate() { if (_firstName == null ||_firstName.trim().equals("")) { //validation errors _firstNameForm.recordError("must have a fname"); return firstNameZone; } else { return null; // let the form submission process continue } } @OnEvent(value = EventConstants.SUCCESS, component="firstNameForm") public Object sucess() { // do whatever you want _modifyFirstName = false; return firstNameZone; } I would like the OnEvent to bubble through to the page. Any nudge in the right direction would be appreciated. --James --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
