what version of T5 are you on? are you using beanedit form? I was using just a regular form and Tapestry didn't display errors if there was no <t:errors/>
On Feb 5, 2008 10:58 AM, Anteneh Alemayehu <[EMAIL PROTECTED]> wrote: > > Good, it is working. > > But, how can I stop displaying the tapestry error messages. > > I didn't include t:errors tag in my form, but the errors (NOT the bubbles) > are keep on displaying. Unless I clear out the errors from the tracker, I > couldn't stop the errors to display. > > Thank you, > Anteneh > > > > > > Adam Zimowski wrote: > > > > Okay, > > > > I created new component "errorMsg" which can be used anywhere on the > > page to display individual error. Enhancements welcome. > > > > This component takes two arguments, a literal string denoting field > > for which error should be rendered, and form to which field is bound. > > The form must be accessible via getter from the class page. > > > > import org.apache.tapestry.Field; > > import org.apache.tapestry.MarkupWriter; > > import org.apache.tapestry.ValidationTracker; > > import org.apache.tapestry.annotations.BeginRender; > > import org.apache.tapestry.annotations.Parameter; > > import org.apache.tapestry.corelib.components.Form; > > > > public class ErrorMsg { > > > > @Parameter > > private String _fieldName; > > > > @Parameter > > private Form _form; > > > > > > public void setFieldName(String aFieldName) { > > _fieldName = aFieldName; > > } > > > > @BeginRender > > void renderMessage(MarkupWriter writer) > > { > > Field f = new Field() { > > public String getElementName() { return _fieldName; } > > public String getLabel() { return null; } > > public boolean isDisabled() { return false; } > > public String getClientId() { return _fieldName; } > > }; > > > > ValidationTracker tracker = _form.getDefaultTracker(); > > String err = tracker.getError(f); > > > > writer.write(err); > > } > > > > public void setForm(Form aForm) { > > _form = aForm; > > } > > } > > > > To display individual error messages simply place <t:errorMsg ../> > > anywhere on the page. It will render the error if there is one for a > > field. > > > > <t:layout xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd"> > > > > <strong><t:errorMsg fieldName="literal:foo" form="form"/></strong> > > > > <t:form t:id="myform"> > > User Name: > > <input type="text" t:type="textfield" t:id="bar" t:value="bar" > > t:validate="required,minlength=3,maxlength=8"/><br/> > > Foo: > > <input type="text" t:type="textfield" t:id="foo" t:value="foo" > > t:validate="required"/> > > <p/> > > <input type="submit" t:type="submit" t:id="submitButton" > > value="Submit"/> > > <p/> > > <t:errorMsg fieldName="literal:bar" form="form"/><br/> > > <!-- you can even display same error twice :) --> > > <t:errorMsg fieldName="literal:bar" form="form"/> > > </t:form> > > > > </t:layout> > > > > > > Page Class: > > > > public class Start { > > > > @Persist > > private String _foo; > > > > @Persist > > private String _bar; > > > > @Component(id="myform") > > private Form _form; > > > > public Form getForm() { > > return _form; > > } > > > > public String getBar() { > > return _bar; > > } > > > > public String getFoo() { > > return _foo; > > } > > } > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > -- > View this message in context: > http://www.nabble.com/Tapestry-5----Overriding-the-form-error-messages-tp15183424p15292922.html > > Sent from the Tapestry - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]