Waffle Taglib for Vraptor Presentation Layer

Waffle taglib is a sample library which aimed at making it easier to create custom forms using the JSP technology. You can find it on http://waffle.codehaus.org/taglib.html.

Installing Waffle Taglib

Download Waffle Taglib and put it on your classpath. Now, all you have to do is to declare waffle taglib on your jsp files:

<%@ taglib uri="http://waffle.codehaus.org" prefix="w" %>  

Example

For our logic:

@Component("person")
public class PersonLogic {

        public void add(Person person) {
                System.out.printf("Adding %s to the database!\n", person);
        }

}

Jsp form will be simply:

 <w:form action="/person.add.logic" type="table" id="sendForm">  
       <w:hidden name="person.id"/>  
       <w:text name="person.name"/>  
       <w:text name="person.address"/>  
       <w:text name="person.preferredNumber"/>    
       <w:submit value="send"/>  
 </w:form> 

And a form for adding a person will be displayed! You must have the following keys on your message.properties:

person.name = Name
person.address = Address
person.preferredNumber = Preferred Number

Or add a label attribute, having same key on message.properties:

<w:text name="person.name" label="name"/>
name=Name

You can use the same form for edition, because the text field will be populated if there is a variable with its name, for instance, if there is a variable person.name = John, the text field named person.name will have John.

For more examples, check Waffle Taglib Documentation.