All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.tapestry5.corelib.components.FormFragment.xdoc Maven / Gradle / Ivy

Go to download

Central module for Tapestry, containing interfaces to the Java Servlet API and all core services and components.

There is a newer version: 5.8.6
Show newest version

    
        

This example will collect a billing address for an order and, optionally, a separate shipping address. Initially, the form will render just the billing address fields:

Clicking the checkbox will trigger an animation that slides down the remainder of the form.

The FormFragment component ensures that client-side validation is only enabled for fields that are actually visible to the user. In addition, for fields that are enclosed within the FormFragment, server-side validation and processing only occurs if the fields were visible to the user when the client-side form was submitted.

Order Address

Billing Address

Separate Ship To?

Shipping Address

]]>

The separateShipTo property is initially null, so the FormFragment is initially invisible. The BeanEditor and all of the individual fields are rendered, but the <div> for the FormFragment is simply invisible.

The TriggerFragment mixin adds a client-side trigger that will show or hide the fragment as the checkbox is clicked by the user.

The OrderAddress page is largely just a holder of the properties (for simplicity in this example, there is no event handler for the success event, nor are we going into other details that would be reflected in a real application).

The BeanEditor component will create default instances of billingAddress and shippingAddress. If the user does not choose to use a seperate ship-to, the shippingAddress property will contain an empty ShippingAddress object. The application will need to query the separateShipTo property to determine how to proceed once the form is succesfully submitted.

FormFragments are nestable, which can lead to complex (and perhaps, confusing) interfaces.

The FormFragment doesn't just prevent server-side input validation when invisible; it prevents any server-side processing for the components it encloses, as if the components were entirely absent.

If JavaScript is disabled on the client, the application will still operate, though the user will have to submit the form to have the fragment(s) update.





© 2015 - 2024 Weber Informatics LLC | Privacy Policy