Next (element)

From JRapid

(Redirected from Next)
Jump to: navigation, search

next is an element child of entity.



The next element specifies an action to be taken after a form has been submitted.

JRapid provides four built-in next types that offer common useful functionality:

The next function is the more general case and allows the developer to implement any special case needed that is not supported by the other three types.


<entity ... >
      type = "function" | "report" | "panel" | "message"
      function = FUNCTION 
      report = REPORT 
      panel = PANEL
      message = MESSAGE
      pdf = "pdf"

Next Function

When using next of type function, a JavaScript function will be called after form submission. This type must be used in conjunction with the function attribute to specify the name of the JavaScript function to be called. Make sure this function is defined and loaded with the corresponding form (check usescript for more info on this).

The specified function receives two parameters: key and me.

key is the value returned by the store() method in the Java services layer that is executed when the form is submitted.

The me parameter is a reference to the form's submit button element in the DOM tree.

A very simple example shows how to raise an alert message with the value returned from the create operation, the id assigned to the new record of a Person entity.

    <entity label="Person" menu="Menu" name="Person">
        <property display="primary" label="First Name" name="firstName"/>
        <property display="primary" label="Last Name" name="lastName"/>
        <property label="Date Of Birth" name="dateOfBirth" type="date" widget="jdatepicker" />

        <next function="mySetFormInfo" type="function"/>


And the JavaScript function, mySetFormInfo, is the following.

function mySetFormInfo(key, me) {
	alert('Returned value: ' + key);	

The behavior after the form submission is shown next.

Next function example‎

Next Report

The next element with the type attribute set to report will open a report after a form is submitted. This expects the report attribute to be set with the name of the report element.

A pdf attribute can be set too to force the report to be rendered as a PDF file.

    <entity label="Work Order" menu="Menu" name="WorkOrder">
        <property display="primary" label="Customer" name="customer"/>
        <property display="primary" label="Order Date" name="orderDate" type="date"/>
        <property label="Description" name="description" type="text"/>

        <next report="WorkOrderReport" type="report"/>

    <report file="WEB-INF/reports/WorkOrder.jasper" location="application" name="WorkOrderReport"/>

When a next report element is created, the store method for the entity returns a string with the concatenation of the properties and corresponding values on the form in URL parameters format. This is then passed to the report servlet so that the Jasper object receives the values as parameters.

For the example above, the store method in the WorkOrderServicesAbstract class is generated with the following code that builds the string to be returned.

// return report params
StringBuffer buf = new StringBuffer();

buf.append("&customer=" + voobj.getCustomer());
buf.append("&orderDate=" + voobj.getOrderDate());
buf.append("&description=" + voobj.getDescription());

return buf.toString();

Keep in mind that you can always overwrite the store method in the WorkOrderServices class to add or change the parameters passed to the report.

Next Panel

If next is set with the panel type, then the user will be redirected to the panel specified in the panel attribute.

This example shows a form where a new user has to complete his profile info and is then redirected to the user panel.

    <panel name="UserPanel" title="User Panel">
        <header><![CDATA[<h1>JRapid Project - User Panel</h1>]]></header>

    <entity label="User Settings" menu="Menu" name="UserSettings">
        <property display="primary" label="First Name" name="firstName"/>
        <property display="primary" label="Last Name" name="lastName"/>
        <property label="Date Of Birth" name="dateOfBirth" type="date"/>
        <property label="Email" name="email" type="email"/>
        <property label="Phone" name="phone"/>
        <property label="Mobile" name="mobile"/>

        <next panel="UserPanel" type="panel"/>

Next Message

The next message type replaces the form contents with the string value of the message attribute.

     <entity label="Contact Us" menu="Menu" name="ContactUs">
        <property display="primary" hidden="hidden" label="Name" name="name"/>
        <property label="Contact Date" name="contactDate" type="datetime" hidden="hidden" default="now" />
        <property display="primary" label="Subject" name="subject"/>
        <property label="Message" name="message" type="text"/>

        <next message="Message sent! Thanks!" type="message "/>

This image shows the form before and after submission.

Next message example‎

See also

Personal tools