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



      

Reply via email to