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 <[EMAIL PROTECTED]> 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>
<input jwcid="[EMAIL PROTECTED]" 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]