Data Tags

From AgileApps Support Wiki

Platform specific Data Tags. These map to the Java APIs getRecord (for getting a single record by Id) and searchRecords (for getting a collection of records for a search criteria, with paging support) calls. These tags have some common attributes that are specified below.

Common attributes for data tags

Attribute Type Description
object String id or name of the user defined object
fieldList String A comma-separated list with the names of fields to retrieve.
controller String If value is "Platform", platform will retrieve the values in a data structure. Any other value will be treated as a user written controller class.
controllerMethod String The controller method to execute. (Required when using a custom controller.)
name String Name of the HTML form element which is rendered as a result of this tag.
onError String Relative URL to execute on error of the operation.
onSuccess String Relative URL to execute on success of the operation.
prefill Boolean Specifies whether the values should be prefilled for the form elements within this form. Prefill logic first looks at the HttpServletRequest.getParameter("form element"). If the value is present it will render it from there, otherwise it will take it from the value attribute of the form element. This is specifically used for error handling.
recordVariable String PageContext variable name. The result of the execution of controller (Platform/User Written) is returned as this PageContext variable. In case of Platform controller, the result object is always an instance of Result Class from Java API.
arg1 - arg10 String 10 Custom arguments that you can pass from the JSP to the controller. Especially useful when you are handling the data retrieval part using custom Controllers.
Considerations
  • The following reserved words cannot be used as the name of the recordVariable:
applicationScope 
cookie 
header 
headerValues 
initParam
pageContext 
pageScope 
param 
paramValues 
request
requestScope 
response 
servletContext 
session 
sessionScope 
Learn more: Implicit Objects in JSP expressions.

Available Data Tags

Action Tag Description Syntax
Detail Data Tag Retrieves a single record from the database for an object <lj:detailData controller="Platform" object="ticket" recordId="${empty param.id? \"-1\" : param.id}"
List Data Tag Retrieves a list of records from the database for an object <lj:listData object="jobPost" controller="JobController" controllerMethod="search" arg1="${param.search}"
Detail Data Tag

Retrieves a single record from the database Can be used standalone, or with a form tag to pre-populate some fields.

Attribute Type Description
recordId String Id of the record being retrieved from the Platform.


Example
<%@taglib prefix="lj" uri="/LJTagLib"%>
<lj:form action="${empty param.action ? \"add\" : param.action}" 
  controller="Platform" object="ticket" onSuccess="pages/ticketList.jsp" onError="pages/ticket.jsp" prefill="true" method="POST">
<lj:detailData controller="Platform" object="ticket" recordId="${empty param.id? \"-1\" : param.id}" 
    recordVariable="ticket" fieldList="subject,description,type,status">
<table border="0" cellspacing="0" cellpadding="5">
    <tr><td ${empty __response ? "" : (__response.code < 0 ? "style=\"color:red\"" : "")} colspan="2">
    ${empty __response ? "" : __response.message}
    </td></tr>
    <input type="hidden" name="id" value="${empty param.id ? "-1" : param.id}" />
    <tr>
		<td align="right" valign="top"><b>Subject</b></td>
		<td align="left"><lj:text name="subject" id="subject" size="50" value="${ticket.parameters.subject}"/></td>
    </tr>
    <tr>
		<td align="right" valign="top"><b>Description</b></td>
		<td align="left"><lj:textArea name="description" cols="50" rows="3" id="description" value="${ticket.parameters.description}"/></td>
    </tr>
    <tr>
		<td align="right" valign="top"><b>Type</b></td>
		<td align="left">
<lj:select name="type" id="Type">
	<lj:option value="fr" source="${ticket.parameters.type}" displayValue="Feature Request" />
	<lj:option value="ti" source="${ticket.parameters.type}" displayValue="Technical Issue" />
	<lj:option value="tq" source="${ticket.parameters.type}" displayValue="Technical Question" />
	<lj:option value="bi" source="${ticket.parameters.type}" displayValue="Billing Issue" />
	<lj:option value="bq" source="${ticket.parameters.type}" displayValue="Billing Question" />
	<lj:option value="ot" source="${ticket.parameters.type}" displayValue="Other" />
</lj:select>
	</td>
	</tr>
    <lj:hidden name="status" id="status" value="${empty ticket.parameters.status ? \"ne\" : ticket.parameters.status}" />
    <tr>
		<td align="right">
		${(empty param.action || param.action == "view")? "" : 
		"<input type=\"submit\" name=\"submit\" id=\"submit\" value=\"Submit\" />" }
		</td>
		<td align="left"><input type="button" name="cancel" value="Cancel" 
        onClick="window.location = '<lj:url resource="pages/ticketList.jsp"/>?fieldList=number,type,subject,status,date_modified,description&sortBy=number&sortOrder=desc&page=0&pageSize=25';" /></td>
    </tr>
</table>
  </lj:detailData>
</lj:form>
List Data Tag

Retrieves a list of records from the database for a Platform object. This tag acts as a loop. It gives an implicit variable "loopIndex" which acts as the loop index/counter.

Attribute Type Description
filter String A filter to get records from the platform. Please see Filter Language.
page Integer Number of the page/offset required for paging of records. Default is 0 (which is the first page)
pageSize Integer Size of the page required for paging of records. Default is taken from ISV settings.
sortBy String Name of the field to sort the data first.
sortBy2 String Name of the field to sort the data second.
sortOrder String Sort order for the sortBy field. Possible values are asc/desc
sortOrder2 String Sort order for the sortBy2 field. Possible values are asc/desc
Example
<%@taglib prefix="lj" uri="/LJTagLib"%>
<lj:listData object="jobPost" 
    controller="com.platform.{namespace}.{package}.{ControllerClass}" 
    controllerMethod="search" arg1="${param.search}" 
    recordVariable="jobPost" page="<%=pageNum%>" pageSize="<%=pageSize%>">
  <tr>
     <td valign="top">
<a href='<lj:url resource="pages/jbPost.jsp"/>?id=${jobPost.record_id}&search=${param.search}'>${jobPost.jrNumber}</a></td>
     <td valign="top">
<a href='<lj:url resource="pages/jbPost.jsp"/>?id=${jobPost.record_id}&search=${param.search}'>${jobPost.title}</a></td>
     <td valign="top">${jobPost.location}</td>
     <td valign="top">${jobPost.date_created}</td>
     <td valign="top">${jobPost.description}</td>
  </tr>
</lj:listData>