You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@click.apache.org by C Jennings <co...@yahoo.com> on 2010/08/03 19:23:27 UTC
setRequired method not working with HtmlForm?
Hello -
I ran into a problem when using the HtmlForm approach (as explained on Page 46 -
49 of Click User Manual titled "Programmatic Layout").
The problem is that I am unable to get the setRequired() method to work.
Everything else works fine and it provides a much cleaner layout that works more
seamlessly with a CSS stylesheet.
Belowis my helper method that is referred to in the manual and all I did was
pass in either a true or false and then call the
setRequired() method. This did not work however during testing as I could enter
a form with no input and it did not produce the Click generated error messages.
It does work fine when I swap back to the Form approach.
Has anyone run into this problem and if so, could you please explain how you
could resolve this issue.
Thank you..
Conor
// Provide a helper method to add text fields to the form
private void addTextField(String nameStr, String labelStr, boolean
isRequired, HtmlList list) {
// Create a new ListItem <li> and add it to the List
ListItem item = new ListItem();
list.add(item);
// Create a textfield with the specified name
Field field = new TextField(nameStr);
//Denotes whether it is a mandatory field: ** NOT WORKING **
field.setRequired(isRequired);
// Create a field label, which associates the label with the field id.
// label.toString would output: <label for="firstname">Firstname:</name>
FieldLabel label = new FieldLabel(field, labelStr);
// Next add the label and field to the list item.
// item.toString would then produce:
// <li>
// <label for="firstname">Firstname:</name>
// <input type="text" name="firstname" id="form_firstname" value=""
size="20"/>
// </li>
//
item.add(label);
item.add(field);
} // end addTextField
Re: setRequired method not working with HtmlForm?
Posted by Bob Schellink <sa...@gmail.com>.
Hi Conor,
When using HtmlForm you take control of the form layout aas well as error
rendering. If you look at the live example[1] the validation errors are
rendered by wrapping fields in a FeedbackBorder component, however any
strategy can be used.
Hope this helps.
Kind regards
Bob
[1]: http://www.avoka.com/click-examples/form/contact-details.htm
--
View this message in context: http://click.1134972.n2.nabble.com/setRequired-method-not-working-with-HtmlForm-tp5369340p5448837.html
Sent from the click-user mailing list archive at Nabble.com.