Hi Malcolm
We are using the Form.setError(String error) for displaying the error
messages on the Form, referring the Apache Click samples. We generate the
string parameter ‘error’ as an HTML including the java script to focus
relevant ‘Field’, sample code snippet is pasted below. We have also
researched the floating error messages (Form using the jQuery Validator )
provided by ClickClick and JQuery integration
(jquery-examples/ajax/validation/jquery-validation1-demo.htm).
I would be interested to know more about the ‘*flash variables*’. I would
appreciate, if you can please elaborate more on topic and guide me with an
hosted example/sample (if any).
private String getError(Field field) {
StringBuffer buffer = new StringBuffer();
buffer.append("<br>");
buffer.append("<a class=\"error\"");
buffer.append(" href=\"javascript:");
buffer.append(field.getFocusJavaScript());
buffer.append("\">");
buffer.append(field.getError());
buffer.append("</a>");
return buffer.toString();
}
Thanks in advance,
Manjit Oberoi
On Fri, Nov 5, 2010 at 3:33 AM, Malcolm Edgar <[email protected]>wrote:
> The best way is to use a flash variable, that way you can redirect to
> another page and still show a message. This supports the post/redirect
> pattern.
>
> regards Malcolm Edgar
>
>
> On Fri, Nov 5, 2010 at 8:11 AM, Yinghai Zhao <[email protected]> wrote:
>
>> Hello,
>> I'm new to Click and writing my first Click web app.
>> I'm wondering what is the best practice to display an error message on a
>> page.
>> Currently, I used a bindable String "msg" in may base page class, and a
>> msg tag in my template.
>> When needed, I just set a value to a "msg" and it get displayed in the
>> page.
>>
>> Then I realize that this is not the best way(actually a silly way) to do
>> this, since the message will be passed through multiple response(and
>> displayed multiple times).
>> Is there a best way to handle this situation? some thing like error()
>> method in Wicket or flash in ruby on rails.
>>
>> Thanks
>> Hai
>>
>
>