You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Ulrich Stärk <ul...@spielviel.de> on 2007/05/03 18:43:23 UTC

@Delegator is not showing validation errors

Hi list,

I've constructed a small test case using Tapestry 4.1.1. I'm trying to validate a text input field 
using the 'required' validator. The FieldLabel for this TextField is indicating an error, but the 
Delegator doesn't display it.

This is my template:

<font color="red"><b><span jwcid="@Delegator" 
delegate="ognl:beans.delegate.firstError"></span></b></font><br/><br/>
<form jwcid="@Form" delegator="ognl:beans.delegate" success="listener:doTest">
   <label jwcid="@FieldLabel" field="component:testField">Test</label>&nbsp;
   <input jwcid="testField@TextField" value="ognl:test" displayName="Test" 
validators="validators:required" />
   <br/><br/>
   <input jwcid="@Submit" />
</form>

The page-specification for this page contains nothing except for the corresponding class reference.
The page class looks like this:

public abstract class Test extends BasePage {
     @Override public String getClientId() { return null; }
     @Override public void setClientId(String arg0) { }

     @Bean public abstract ValidationDelegate getDelegate();
     @InjectPage("Home") public abstract IPage getHomePage();
     public abstract String getTest();

     public IPage doTest() {
         if(getDelegate().getHasErrors())
             return null;
         System.out.println(getTest());
         return getHomePage();
     }
}

After fighting with this for 4 hours I've got the strong feeling that I'm missing something here. So 
all you experts out there please help me :)

Cheers

Uli

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


Re: @Delegator is not showing validation errors

Posted by Ulrich Stärk <ul...@spielviel.de>.
Thanks for your help Jesse,

I know now why you should always obey to these: http://www.debuggingrules.com/debuggingrules.jpg - 
especially rule #3 :)
I specified the ValidationDelegate in the Form component using a 'delegator' attribute where it 
should read 'delegate'. 2 characters, big impact.

Sorry for the inconvenience.

Uli

Ulrich Stärk schrieb:
> According to the API doc ValidationDelegate.getFirstError() does exactly 
> that - returning an IRender instance used to render the first error - 
> http://tapestry.apache.org/tapestry4.1/apidocs/org/apache/tapestry/valid/ValidationDelegate.html#getFirstError() 
> 
> I think the problem lies somewhere else namely that the 
> ValidationDelegate doesn't record the error if you leave the TextField 
> empty. Any idea why this could be?
> 
> Cheers
> 
> Uli
> 
> Jesse Kuhnert schrieb:
>> This is a lazy answer, but I don't think the default ValidationDelegate
>> provided by tapestry actually renders the error message - it just marks
>> things as being in error. (perhaps the default should be the other way
>> around ? )
>>
>> You can see an example of how to extend the validationdelegate to do what
>> you want at the bottom of this page:
>>
>> http://tapestry.apache.org/tapestry4.1/usersguide/validation.html
>>
>> Something along the lines of your @Delegate component (which I'm 
>> assuming is
>> supposed to print out all the error messages? ) is also found here:
>> http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/java/org/apache/tapestry/workbench/components/form/ShowError.java?view=markup 
>>
>>
>> Note that this particular example only prints out the first error, not 
>> all
>> of them.
>>
>> On 5/3/07, Ulrich Stärk <ul...@spielviel.de> wrote:
>>>
>>> Hi list,
>>>
>>> I've constructed a small test case using Tapestry 4.1.1. I'm trying to
>>> validate a text input field
>>> using the 'required' validator. The FieldLabel for this TextField is
>>> indicating an error, but the
>>> Delegator doesn't display it.
>>>
>>> This is my template:
>>>
>>> <font color="red"><b><span jwcid="@Delegator"
>>> delegate="ognl:beans.delegate.firstError"></span></b></font><br/><br/>
>>> <form jwcid="@Form" delegator="ognl:beans.delegate"
>>> success="listener:doTest">
>>>    <label jwcid="@FieldLabel"
>>> field="component:testField">Test</label>&nbsp;
>>>    <input jwcid="testField@TextField" value="ognl:test" 
>>> displayName="Test"
>>> validators="validators:required" />
>>>    <br/><br/>
>>>    <input jwcid="@Submit" />
>>> </form>
>>>
>>> The page-specification for this page contains nothing except for the
>>> corresponding class reference.
>>> The page class looks like this:
>>>
>>> public abstract class Test extends BasePage {
>>>      @Override public String getClientId() { return null; }
>>>      @Override public void setClientId(String arg0) { }
>>>
>>>      @Bean public abstract ValidationDelegate getDelegate();
>>>      @InjectPage("Home") public abstract IPage getHomePage();
>>>      public abstract String getTest();
>>>
>>>      public IPage doTest() {
>>>          if(getDelegate().getHasErrors())
>>>              return null;
>>>          System.out.println(getTest());
>>>          return getHomePage();
>>>      }
>>> }
>>>
>>> After fighting with this for 4 hours I've got the strong feeling that 
>>> I'm
>>> missing something here. So
>>> all you experts out there please help me :)
>>>
>>> Cheers
>>>
>>> Uli
>>>
>>> ---------------------------------------------------------------------
>>> 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: @Delegator is not showing validation errors

Posted by Ulrich Stärk <ul...@spielviel.de>.
According to the API doc ValidationDelegate.getFirstError() does exactly that - returning an IRender 
instance used to render the first error - 
http://tapestry.apache.org/tapestry4.1/apidocs/org/apache/tapestry/valid/ValidationDelegate.html#getFirstError()
I think the problem lies somewhere else namely that the ValidationDelegate doesn't record the error 
if you leave the TextField empty. Any idea why this could be?

Cheers

Uli

Jesse Kuhnert schrieb:
> This is a lazy answer, but I don't think the default ValidationDelegate
> provided by tapestry actually renders the error message - it just marks
> things as being in error. (perhaps the default should be the other way
> around ? )
> 
> You can see an example of how to extend the validationdelegate to do what
> you want at the bottom of this page:
> 
> http://tapestry.apache.org/tapestry4.1/usersguide/validation.html
> 
> Something along the lines of your @Delegate component (which I'm 
> assuming is
> supposed to print out all the error messages? ) is also found here:
> http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/java/org/apache/tapestry/workbench/components/form/ShowError.java?view=markup 
> 
> 
> Note that this particular example only prints out the first error, not all
> of them.
> 
> On 5/3/07, Ulrich Stärk <ul...@spielviel.de> wrote:
>>
>> Hi list,
>>
>> I've constructed a small test case using Tapestry 4.1.1. I'm trying to
>> validate a text input field
>> using the 'required' validator. The FieldLabel for this TextField is
>> indicating an error, but the
>> Delegator doesn't display it.
>>
>> This is my template:
>>
>> <font color="red"><b><span jwcid="@Delegator"
>> delegate="ognl:beans.delegate.firstError"></span></b></font><br/><br/>
>> <form jwcid="@Form" delegator="ognl:beans.delegate"
>> success="listener:doTest">
>>    <label jwcid="@FieldLabel"
>> field="component:testField">Test</label>&nbsp;
>>    <input jwcid="testField@TextField" value="ognl:test" 
>> displayName="Test"
>> validators="validators:required" />
>>    <br/><br/>
>>    <input jwcid="@Submit" />
>> </form>
>>
>> The page-specification for this page contains nothing except for the
>> corresponding class reference.
>> The page class looks like this:
>>
>> public abstract class Test extends BasePage {
>>      @Override public String getClientId() { return null; }
>>      @Override public void setClientId(String arg0) { }
>>
>>      @Bean public abstract ValidationDelegate getDelegate();
>>      @InjectPage("Home") public abstract IPage getHomePage();
>>      public abstract String getTest();
>>
>>      public IPage doTest() {
>>          if(getDelegate().getHasErrors())
>>              return null;
>>          System.out.println(getTest());
>>          return getHomePage();
>>      }
>> }
>>
>> After fighting with this for 4 hours I've got the strong feeling that I'm
>> missing something here. So
>> all you experts out there please help me :)
>>
>> Cheers
>>
>> Uli
>>
>> ---------------------------------------------------------------------
>> 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: @Delegator is not showing validation errors

Posted by Jesse Kuhnert <jk...@gmail.com>.
This is a lazy answer, but I don't think the default ValidationDelegate
provided by tapestry actually renders the error message - it just marks
things as being in error. (perhaps the default should be the other way
around ? )

You can see an example of how to extend the validationdelegate to do what
you want at the bottom of this page:

http://tapestry.apache.org/tapestry4.1/usersguide/validation.html

Something along the lines of your @Delegate component (which I'm assuming is
supposed to print out all the error messages? ) is also found here:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/java/org/apache/tapestry/workbench/components/form/ShowError.java?view=markup

Note that this particular example only prints out the first error, not all
of them.

On 5/3/07, Ulrich Stärk <ul...@spielviel.de> wrote:
>
> Hi list,
>
> I've constructed a small test case using Tapestry 4.1.1. I'm trying to
> validate a text input field
> using the 'required' validator. The FieldLabel for this TextField is
> indicating an error, but the
> Delegator doesn't display it.
>
> This is my template:
>
> <font color="red"><b><span jwcid="@Delegator"
> delegate="ognl:beans.delegate.firstError"></span></b></font><br/><br/>
> <form jwcid="@Form" delegator="ognl:beans.delegate"
> success="listener:doTest">
>    <label jwcid="@FieldLabel"
> field="component:testField">Test</label>&nbsp;
>    <input jwcid="testField@TextField" value="ognl:test" displayName="Test"
> validators="validators:required" />
>    <br/><br/>
>    <input jwcid="@Submit" />
> </form>
>
> The page-specification for this page contains nothing except for the
> corresponding class reference.
> The page class looks like this:
>
> public abstract class Test extends BasePage {
>      @Override public String getClientId() { return null; }
>      @Override public void setClientId(String arg0) { }
>
>      @Bean public abstract ValidationDelegate getDelegate();
>      @InjectPage("Home") public abstract IPage getHomePage();
>      public abstract String getTest();
>
>      public IPage doTest() {
>          if(getDelegate().getHasErrors())
>              return null;
>          System.out.println(getTest());
>          return getHomePage();
>      }
> }
>
> After fighting with this for 4 hours I've got the strong feeling that I'm
> missing something here. So
> all you experts out there please help me :)
>
> Cheers
>
> Uli
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Jesse Kuhnert
Tapestry/Dojo team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com