You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Anteneh Alemayehu <ab...@gmail.com> on 2008/01/30 16:15:57 UTC

Tapestry[5] - Overriding the form error messages

Hi Everyone,

I have a specific message area on the top of the page to display the eror
messages.

I might have more than one form per page, 

How can I overide the error messges from the form validation and display on
the message area.

Any Idea?

Thank you,
Anteneh
-- 
View this message in context: http://www.nabble.com/Tapestry-5----Overriding-the-form-error-messages-tp15183424p15183424.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: Tapestry[5] - Overriding the form error messages

Posted by Anteneh Alemayehu <ab...@gmail.com>.
Hi Everyone,

Please see the following fragment code which I tried to override the form
error messages:

The plan is to copy the errors from the validation tracker in to my error
model, and clear the errors from the validation tracker. (At this point I
have the errors in my errors model and also the form is free from errors to
display). 

My problem is either
         to get the error from the validation tracker by property name
         or to get the Field object dynamically from property name

1. Validation tracker has no functionality to get error by property name
2. There is getError by Field, this will be to much work to declare a
component for each field in my form

I can get the List<String> errors from the tracker, but I need Map<String,
String> errors, where property name is a field, to use the information in
MyLabel component, which will take care to hilight the labels.

@Inject
private Environment environment;

MyErrorModel myErrorModel;

private Object onSubmit() {
    ValidationTracker tracker = environment.peek(ValidationTracker.class);
    
    Map<String, String> errors = tracker.getErrorsMap();
    
	if (null != getSystemMessages() && !getSystemMessages().isEmpty()) {
		
		List<String> propertyNames = userModel.getPropertyNames();
		for(String propertyName: propertyNames) {
			myErrorModel.addError(propertyName, NEED_YOUR_HELP);
		}
		
                beanEditForm.clearErrors();
		return null;
	}
		
        displayEmployee.setup(employee);
		
	return displayEmployee;
    }





Adam Zimowski wrote:
> 
> I'm also interested to know if individual error messages are
> completely customisable in a way that a particular error message can
> be styled (bubble or not) and placed *anywhere* on the page
> irrespective of where other error messages and form components are.
> 
> Without a clear answer so far, does it mean that it is not possible at
> the moment?
> 
> -adam
> 
> On Jan 31, 2008 8:48 AM, Geoff Callender
> <ge...@gmail.com> wrote:
>> I agree.  I do like the bubbles and I do like the previous style, but
>> to maximise uptake of T5 it may be best to make the choice of message
>> display configurable in AppModule and overridable at the page level.
>> A third display type could also be offered - message alongside/below/
>> above the field in error (not hovering).  CSS for each type would
>> allow fine-tuning.
>>
>> Just my two cents worth,
>>
>> Geoff
>>
>>
>> On 31/01/2008, at 8:41 AM, Anteneh Alemayehu wrote:
>>
>> >
>> > Thanks Howard,
>> >
>> > I saw that and I personally like the popup bubbles feature,
>> >
>> > But there is a requierement to override and display all the error
>> > messages
>> > in one specific Message area.
>> >
>> > Thanks again,
>> > Anteneh
>> >
>> >
>> >
>> > Howard Lewis Ship wrote:
>> >>
>> >> Starting with 5.0.9, the validation errors appear as popup bubbles
>> >> adjacent to the fields.
>> >>
>> >> On Jan 30, 2008 7:15 AM, Anteneh Alemayehu <ab...@gmail.com> wrote:
>> >>>
>> >>> Hi Everyone,
>> >>>
>> >>> I have a specific message area on the top of the page to display
>> >>> the eror
>> >>> messages.
>> >>>
>> >>> I might have more than one form per page,
>> >>>
>> >>> How can I overide the error messges from the form validation and
>> >>> display
>> >>> on
>> >>> the message area.
>> >>>
>> >>> Any Idea?
>> >>>
>> >>> Thank you,
>> >>> Anteneh
>> >>> --
>> >>> View this message in context:
>> >>>
>> http://www.nabble.com/Tapestry-5----Overriding-the-form-error-messages-tp15183424p15183424.html
>> >>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>> >>>
>> >>>
>> >>> ---------------------------------------------------------------------
>> >>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> >>> For additional commands, e-mail: users-help@tapestry.apache.org
>> >>>
>> >>>
>> >>
>> >>
>> >>
>> >> --
>> >> Howard M. Lewis Ship
>> >>
>> >> Creator Apache Tapestry and Apache HiveMind
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> >> For additional commands, e-mail: users-help@tapestry.apache.org
>> >>
>> >>
>> >>
>> >
>> > --
>> > View this message in context:
>> http://www.nabble.com/Tapestry-5----Overriding-the-form-error-messages-tp15183424p15192789.html
>> > Sent from the Tapestry - User mailing list archive at Nabble.com.
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> > For additional commands, e-mail: users-help@tapestry.apache.org
>> >
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Tapestry-5----Overriding-the-form-error-messages-tp15183424p15231877.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: Tapestry[5] - Overriding the form error messages

Posted by Adam Zimowski <zi...@gmail.com>.
I'm also interested to know if individual error messages are
completely customisable in a way that a particular error message can
be styled (bubble or not) and placed *anywhere* on the page
irrespective of where other error messages and form components are.

Without a clear answer so far, does it mean that it is not possible at
the moment?

-adam

On Jan 31, 2008 8:48 AM, Geoff Callender
<ge...@gmail.com> wrote:
> I agree.  I do like the bubbles and I do like the previous style, but
> to maximise uptake of T5 it may be best to make the choice of message
> display configurable in AppModule and overridable at the page level.
> A third display type could also be offered - message alongside/below/
> above the field in error (not hovering).  CSS for each type would
> allow fine-tuning.
>
> Just my two cents worth,
>
> Geoff
>
>
> On 31/01/2008, at 8:41 AM, Anteneh Alemayehu wrote:
>
> >
> > Thanks Howard,
> >
> > I saw that and I personally like the popup bubbles feature,
> >
> > But there is a requierement to override and display all the error
> > messages
> > in one specific Message area.
> >
> > Thanks again,
> > Anteneh
> >
> >
> >
> > Howard Lewis Ship wrote:
> >>
> >> Starting with 5.0.9, the validation errors appear as popup bubbles
> >> adjacent to the fields.
> >>
> >> On Jan 30, 2008 7:15 AM, Anteneh Alemayehu <ab...@gmail.com> wrote:
> >>>
> >>> Hi Everyone,
> >>>
> >>> I have a specific message area on the top of the page to display
> >>> the eror
> >>> messages.
> >>>
> >>> I might have more than one form per page,
> >>>
> >>> How can I overide the error messges from the form validation and
> >>> display
> >>> on
> >>> the message area.
> >>>
> >>> Any Idea?
> >>>
> >>> Thank you,
> >>> Anteneh
> >>> --
> >>> View this message in context:
> >>> http://www.nabble.com/Tapestry-5----Overriding-the-form-error-messages-tp15183424p15183424.html
> >>> Sent from the Tapestry - User mailing list archive at Nabble.com.
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >>> For additional commands, e-mail: users-help@tapestry.apache.org
> >>>
> >>>
> >>
> >>
> >>
> >> --
> >> Howard M. Lewis Ship
> >>
> >> Creator Apache Tapestry and Apache HiveMind
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> For additional commands, e-mail: users-help@tapestry.apache.org
> >>
> >>
> >>
> >
> > --
> > View this message in context: http://www.nabble.com/Tapestry-5----Overriding-the-form-error-messages-tp15183424p15192789.html
> > Sent from the Tapestry - User mailing list archive at Nabble.com.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

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


Re: Tapestry[5] - Overriding the form error messages

Posted by Geoff Callender <ge...@gmail.com>.
I agree.  I do like the bubbles and I do like the previous style, but  
to maximise uptake of T5 it may be best to make the choice of message  
display configurable in AppModule and overridable at the page level.   
A third display type could also be offered - message alongside/below/ 
above the field in error (not hovering).  CSS for each type would  
allow fine-tuning.

Just my two cents worth,

Geoff

On 31/01/2008, at 8:41 AM, Anteneh Alemayehu wrote:

>
> Thanks Howard,
>
> I saw that and I personally like the popup bubbles feature,
>
> But there is a requierement to override and display all the error  
> messages
> in one specific Message area.
>
> Thanks again,
> Anteneh
>
>
>
> Howard Lewis Ship wrote:
>>
>> Starting with 5.0.9, the validation errors appear as popup bubbles
>> adjacent to the fields.
>>
>> On Jan 30, 2008 7:15 AM, Anteneh Alemayehu <ab...@gmail.com> wrote:
>>>
>>> Hi Everyone,
>>>
>>> I have a specific message area on the top of the page to display  
>>> the eror
>>> messages.
>>>
>>> I might have more than one form per page,
>>>
>>> How can I overide the error messges from the form validation and  
>>> display
>>> on
>>> the message area.
>>>
>>> Any Idea?
>>>
>>> Thank you,
>>> Anteneh
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Tapestry-5----Overriding-the-form-error-messages-tp15183424p15183424.html
>>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>
>>
>>
>> -- 
>> Howard M. Lewis Ship
>>
>> Creator Apache Tapestry and Apache HiveMind
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>>
>
> -- 
> View this message in context: http://www.nabble.com/Tapestry-5----Overriding-the-form-error-messages-tp15183424p15192789.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>


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


Re: Tapestry[5] - Overriding the form error messages

Posted by Anteneh Alemayehu <ab...@gmail.com>.
Thanks Howard,

I saw that and I personally like the popup bubbles feature,

But there is a requierement to override and display all the error messages
in one specific Message area.

Thanks again,
Anteneh



Howard Lewis Ship wrote:
> 
> Starting with 5.0.9, the validation errors appear as popup bubbles
> adjacent to the fields.
> 
> On Jan 30, 2008 7:15 AM, Anteneh Alemayehu <ab...@gmail.com> wrote:
>>
>> Hi Everyone,
>>
>> I have a specific message area on the top of the page to display the eror
>> messages.
>>
>> I might have more than one form per page,
>>
>> How can I overide the error messges from the form validation and display
>> on
>> the message area.
>>
>> Any Idea?
>>
>> Thank you,
>> Anteneh
>> --
>> View this message in context:
>> http://www.nabble.com/Tapestry-5----Overriding-the-form-error-messages-tp15183424p15183424.html
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> 
> 
> 
> -- 
> Howard M. Lewis Ship
> 
> Creator Apache Tapestry and Apache HiveMind
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Tapestry-5----Overriding-the-form-error-messages-tp15183424p15192789.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: Tapestry[5] - Overriding the form error messages

Posted by Howard Lewis Ship <hl...@gmail.com>.
Starting with 5.0.9, the validation errors appear as popup bubbles
adjacent to the fields.

On Jan 30, 2008 7:15 AM, Anteneh Alemayehu <ab...@gmail.com> wrote:
>
> Hi Everyone,
>
> I have a specific message area on the top of the page to display the eror
> messages.
>
> I might have more than one form per page,
>
> How can I overide the error messges from the form validation and display on
> the message area.
>
> Any Idea?
>
> Thank you,
> Anteneh
> --
> View this message in context: http://www.nabble.com/Tapestry-5----Overriding-the-form-error-messages-tp15183424p15183424.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

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


Re: Tapestry[5] - Overriding the form error messages

Posted by DavidWei <xi...@rrd.com>.
Here is the stock trace:

Stack trace 
org.apache.tapestry.ioc.internal.services.TypeCoercerImpl.findOrCreateCoercion(TypeCoercerImpl.java:248) 
org.apache.tapestry.ioc.internal.services.TypeCoercerImpl.findCoercion(TypeCoercerImpl.java:168) 
org.apache.tapestry.ioc.internal.services.TypeCoercerImpl.coerce(TypeCoercerImpl.java:120) 
org.apache.tapestry.internal.structure.InternalComponentResourcesImpl.readParameter(InternalComponentResourcesImpl.java:200) 
com.rrd.sbmaker.web.components.ErrorMsg._$read_parameter_form(ErrorMsg.java) 
com.rrd.sbmaker.web.components.ErrorMsg.renderMessage(ErrorMsg.java:33) 
com.rrd.sbmaker.web.components.ErrorMsg.beginRender(ErrorMsg.java) 
org.apache.tapestry.internal.structure.ComponentPageElementImpl$10$1.run(ComponentPageElementImpl.java:330) 
org.apache.tapestry.internal.structure.ComponentPageElementImpl.invoke(ComponentPageElementImpl.java:891) 
org.apache.tapestry.internal.structure.ComponentPageElementImpl.access$100(ComponentPageElementImpl.java:56) 
org.apache.tapestry.internal.structure.ComponentPageElementImpl$10.render(ComponentPageElementImpl.java:334) 
org.apache.tapestry.internal.services.RenderQueueImpl.run(RenderQueueImpl.java:58) 
org.apache.tapestry.internal.services.PageRenderQueueImpl.render(PageRenderQueueImpl.java:58) 
org.apache.tapestry.internal.services.MarkupRendererPipelineImpl$1.renderMarkup(MarkupRendererPipelineImpl.java:39) 
org.apache.tapestry.services.TapestryModule$20.renderMarkup(TapestryModule.java:1349) 
org.apache.tapestry.services.TapestryModule$19.renderMarkup(TapestryModule.java:1330) 
org.apache.tapestry.services.TapestryModule$18.renderMarkup(TapestryModule.java:1312) 
org.apache.tapestry.services.TapestryModule$17.renderMarkup(TapestryModule.java:1294) 
org.apache.tapestry.internal.services.MarkupRendererPipelineImpl.renderMarkup(MarkupRendererPipelineImpl.java:48) 
org.apache.tapestry.internal.services.PageMarkupRendererImpl.renderPageMarkup(PageMarkupRendererImpl.java:55) 
org.apache.tapestry.internal.services.PageResponseRendererImpl.renderPageResponse(PageResponseRendererImpl.java:56) 
org.apache.tapestry.internal.services.PageRenderRequestHandlerImpl.handle(PageRenderRequestHandlerImpl.java:87) 
org.apache.tapestry.internal.services.PageRenderDispatcher.dispatch(PageRenderDispatcher.java:66) 
org.apache.tapestry.services.TapestryModule$12.service(TapestryModule.java:905) 
org.apache.tapestry.internal.services.LocalizationFilter.service(LocalizationFilter.java:43) 
org.apache.tapestry.services.TapestryModule$2.service(TapestryModule.java:487) 
org.apache.tapestry.internal.services.StaticFilesFilter.service(StaticFilesFilter.java:79) 
org.apache.tapestry.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:94) 
org.apache.tapestry.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:85) 
org.apache.tapestry.ioc.internal.util.ConcurrentBarrier.withRead(ConcurrentBarrier.java:77) 
org.apache.tapestry.internal.services.CheckForUpdatesFilter.service(CheckForUpdatesFilter.java:107) 
org.apache.tapestry.services.TapestryModule$11.service(TapestryModule.java:888) 
org.apache.tapestry.TapestryFilter.doFilter(TapestryFilter.java:164) 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) 
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263) 
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) 
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584) 
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) 
java.lang.Thread.run(Unknown Source) 



Adam Zimowski wrote:
> 
> This doesn't make sense, as there should be no reason to coerce on a
> single type (org.apache.tapestry.corelib.components.Form). What does
> your Start class look like?
> 
> On Feb 4, 2008 9:29 AM, DavidWei <xi...@rrd.com> wrote:
>>
>> I try to run your codes, but got an exception as follows:
>> An unexpected application exception has occurred
>>
>> Failure reading parameter form of component test/Start:errormsg: Could
>> not
>> find a coercion from type org.apache.tapestry.corelib.components.Form to
>> type org.apache.tapestry.corelib.components.Form ...
>>
>> Do I miss anything? Please advise.
>>
>> Thanks,
>>
>>
>>
>>
>>
>> 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: users-unsubscribe@tapestry.apache.org
>> > For additional commands, e-mail: users-help@tapestry.apache.org
>> >
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Tapestry-5----Overriding-the-form-error-messages-tp15183424p15268993.html
>>
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Tapestry-5----Overriding-the-form-error-messages-tp15183424p15291551.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: Tapestry[5] - Overriding the form error messages

Posted by Adam Zimowski <zi...@gmail.com>.
This doesn't make sense, as there should be no reason to coerce on a
single type (org.apache.tapestry.corelib.components.Form). What does
your Start class look like?

On Feb 4, 2008 9:29 AM, DavidWei <xi...@rrd.com> wrote:
>
> I try to run your codes, but got an exception as follows:
> An unexpected application exception has occurred
>
> Failure reading parameter form of component test/Start:errormsg: Could not
> find a coercion from type org.apache.tapestry.corelib.components.Form to
> type org.apache.tapestry.corelib.components.Form ...
>
> Do I miss anything? Please advise.
>
> Thanks,
>
>
>
>
>
> 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: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Tapestry-5----Overriding-the-form-error-messages-tp15183424p15268993.html
>
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

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


Re: Tapestry[5] - Overriding the form error messages

Posted by DavidWei <xi...@rrd.com>.
I try to run your codes, but got an exception as follows:
An unexpected application exception has occurred

Failure reading parameter form of component test/Start:errormsg: Could not
find a coercion from type org.apache.tapestry.corelib.components.Form to
type org.apache.tapestry.corelib.components.Form ...

Do I miss anything? Please advise.

Thanks,




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: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Tapestry-5----Overriding-the-form-error-messages-tp15183424p15268993.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: Tapestry[5] - Overriding the form error messages

Posted by Anteneh Alemayehu <ab...@gmail.com>.
Yes I am using beaneditform, ON T5-version 5.0.7

Thank you,
Anteneh



Adam Zimowski wrote:
> 
> 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 <ab...@gmail.com> 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: users-unsubscribe@tapestry.apache.org
>> > For additional commands, e-mail: users-help@tapestry.apache.org
>> >
>> >
>> >
>>
>> --
>> 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: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Tapestry-5----Overriding-the-form-error-messages-tp15183424p15295418.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: Tapestry[5] - Overriding the form error messages

Posted by Adam Zimowski <zi...@gmail.com>.
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 <ab...@gmail.com> 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: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
> >
>
> --
> 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: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

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


Re: Tapestry[5] - Overriding the form error messages

Posted by Anteneh Alemayehu <ab...@gmail.com>.
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: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
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: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org