Is there a form builder for Java / Spring web applications?

I go from PHP

to Java

and Spring

. I noticed that Spring

even though it's a great framework, it misses out on anything related to other platforms on other platforms. One of the ones I missed the most was the ability to create a form using dedicated pickers without writing a single line html

.

Take Symfony2

for example (click here for the full article):

/**
 * Controller class
 */ 
public function newAction(Request $request)
{
    // create a task and give it some dummy data for this example
    $task = new Task();
    $task->setTask('Write a blog post');
    $task->setDueDate(new \DateTime('tomorrow'));

    $form = $this->createFormBuilder($task)
        ->add('task', 'text')
        ->add('dueDate', 'date')
        ->add('save', 'submit', array('label' => 'Create Post'))
        ->getForm();

    return $this->render('AcmeTaskBundle:Default:new.html.twig', array(
        'form' => $form->createView(),
    ));
}

      

Having this code, all I have to do is call form

(actually a method toString()

, but the corresponding plugin twig

handles this) in my opinion. HTML is generated and populated on the fly:

{{ form(form) }}

      

rendered form, image taken from symfony site

Validation is done on entities (single field and complex validators), but you can also attach validators to form yourself.

Is there a way to achieve this functionality in Spring

?

+3


source to share


1 answer


There are frameworks out there that try to provide you with a tool to easily create things. The problem with them, as a rule, is that the simpler, the more it creates a mess. It doesn't matter for simple projects, but using code generation tools usually carries a risk for assortment software.



Spring provides a RAD (Rapid Application Development) tool called Roo , which probably helps in building the interface as well. I don't know of any popular Java form developers, and given the number of different view technologies available, they will be tied to a specific type (JSF, Tapestry, etc.).

0


source







All Articles