Pages

From LongJump Support Wiki

Setup > Develop > Pages
Jump to: navigation, search
A Page is a standard JSP (JavaServer Page) page. It can be used to create highly customized user interface elements as well as completely independent tabs.
Learn more: Pages in the Developer Suite

In most cases, a page communicates with a worker class through a controller class. For details, see Working with Pages and Classes.

File:Lock-tiny.gif

Users in Roles with Customize Objects permission rights enabled can add, edit or delete pages 


Contents

About APIs

You can make Java API calls in the Java code in a page. The following Java API classes are implicitly imported into pages:

You can also make AJAX API calls in the JavaScript in a page. The AjaxAPI, LongJump.Record, and AjaxInfo objects are implicitly imported into pages.


A page has these restrictions:

  • The maximum number of loop iterations is 10000
  • You cannot make a database connection

A complete list of restrictions is available in the Governors section.

Manage Pages

Pages can be Added, Edited or Deleted. Before editing, a page must be checked out (Checkout), and should be checked in (Commit) after Editing.

Add a Page

To add a page:

  1. Click Setup | Develop | Pages
  2. Click the [New Page] button, and complete the following information:
    Title
    Enter a title for the page
    *.jsp extension is required
    Display with Tab Header
    Checkbox
    If checked, display the page with a tab header
  3. Enter the code in the text area
  4. Click the [Save] button to continue, or [Cancel] to stop the action

Edit a Page

Before editing a page, the page must be checked out. To edit a page:

  1. Click Setup | Develop | Pages
  2. Click the name of the page to edit
  3. Click the [Edit] button
  4. Edit the code in the text area
  5. Click the [Save] button to continue, or [Cancel] to stop the action

Checkout a Page

Before editing a page, the page must be checked out.

Learn more: Version Control

To checkout a page:

  1. Click Setup | Develop | Pages
  2. Click the name of the page to edit
  3. Click the [Checkout] button

Any of the following actions can be taken on a page that is checked out:

  • Edit
  • Delete
  • Commit
  • Back (Cancel)

The following information is displayed when a page is checked out:

Page Information
Title
pagetitle.jsp
Display with Tab Header
Yes
Version Information
Version
4
Locked
No
Last Commit By
Elaine Yoder
Last Commit Date
01/13/2010 10:55 AM
Last Checkout By
Elaine Yoder
Last Checkout Date

Commit a Page

After editing a page, the changes should be committed to the working copy. To commit a page:

  1. After editing a page, click the [Save] button
  2. Click the [Commit] button
    The Item Type and Name cannot be modified
    Add Comments about the changes
    The following Commit Details are displayed:
    Item Type
    Page
    Item Name
    pagename.jsp
    Comment
    Description of the changes to the page
  3. Click the [Save] button to continue, or [Cancel] to stop the action

Delete a Page

To delete a page:

  1. Click Setup | Develop | Pages
  2. Click the name of the page to delete
  3. Click the [Delete] button to continue, or [Cancel] to stop the action

Editing Pages in Eclipse

Use the Eclipse Plug-In to add, edit or delete pages.

Invoke a Page from an Action

  1. Click Setup | Customize | Objects.
  2. Click an object
  3. Click the Actions tab
  4. Click the [Add Action] button
  5. Enter a title
  6. Specify Invoke Custom Page as the Type
  7. Select a page you have defined
  8. Click the [Save] button to continue, or [Cancel] to stop the action

Invoke a Page from a URL

If you have written your page in a way that does not require a controller to display it, you can directly invoke it using:

https://www.longjump.com/networking/pages/MyJSP.jsp

If your page depends on a controller to display it, you can use this type of URL:

https://www.longjump.com/networking/controller/MyService?action=myService

where MyService is a class that implements the Controller interface and action is a parameter that you can use in the controller.

For more about controllers, see see Working with Pages and Classes.

Create a Tab using Pages

See Web Tabs for information on creating tabs using pages.

About Static Resources in Pages

See the Static Resources article for information on how to load image files, stylesheets, JavaScript files or compressed files as Page resources.

Print Templates Using Pages

Print templates in pages can be used to print records in any object. See Print Templates for an overview of print templates in the user interface.

Examples

  • Create an Expense Report to be used in expense management application
  • Print an Employee Benefit Form

Using print templates in pages is a two-step process:

  1. Create a Page that includes the desired print formatting
  2. Create a Print Template using a Page as the template type

Create a Page

  1. Click Setup | Customize | Pages
  2. Click the [New Page] button
  3. Click the [Edit] Button
  4. Enter a Title (filename) for the print template; Include .jsp as the file extension
  5. Uncheck the Display with Tab Header checkbox
  6. Add appropriate code; This example includes a typical "Hello World" example:
  7. Click [Save] to save your changes, or [Cancel] to stop the action

Create a Print Template

This print template uses Page as the type of template, instead of HTML

  1. Click Setup | Customize | Object | <object name>
  2. Add a new Print Template, select Page type and select the .jsp print template file

Extras

Object ID and Record ID are available in the Request Object, and can be accessed from the Page:

 String object_id = request.getParameter("object_id");
 String record_id = request.getParameter("record_id");

Example: Add a Contact using a Page and a Class

This example describes how to Add a Contact using a Page and Class.

Create a Page

  1. To create a page, follow the instructions at Adding a Page
  2. Copy and paste the following code into the page, and name it AddContact.jsp
  1. <body>
  2.  
  3. <form  name = "mainForm" action="/networking/controller/AddContact" method="POST">
  4. <table width="100%" border="10" cellspacing="0" cellpadding="0">
  5.   <tr>
  6.     <td><table width="50%" border="0" cellspacing="0" cellpadding="2">
  7.       <tr>
  8.         <LABEL for="addFirstName">    First Name: </LABEL>
  9.               <INPUT type="text" id="addFirstName" name="addFirstName" value="CPFirst"><BR>
  10.         <LABEL for="addLastName">   Last Name: </LABEL>
  11.               <INPUT type="text" id="addLastName" name="addLastName" value="CPLast"><BR>
  12.  
  13.         <INPUT type="submit" value="Add"> <INPUT type="reset">        
  14.       </tr>
  15.     </table>
  16.     </form>
  17.     </td>
  18.   </tr>
  19.  
  20. </body>
  21. </html>

Create a Class

  1. To create a class, follow the instructions at Adding a Class
  2. Copy and paste the following code into the class, and name it AddContact
  1. import java.util.*;
  2. import com.es.mvc.*;
  3. import com.es.api.scripting.*;
  4.  
  5. public class AddContact implements Controller
  6. {
  7.     public ControllerResponse execute(HashMap params) throws Exception
  8.     {
  9.        String action = (String)params.get("action");
  10.  
  11.        if(action == null || action.equals(""))
  12.        {
  13.             debug("Action - null?");            
  14.             action = "Add";
  15.        }
  16.        if(action.equals("Add"))
  17.        {
  18.              debug("Action - not null?" + action);
  19.              return addContact(params);
  20.        }
  21.        else
  22.        {
  23.  
  24.        }
  25.          return null;
  26.  }
  27.  
  28.  private ControllerResponse addContact(HashMap params) throws Exception
  29.  {
  30.      ControllerResponse cr = new ControllerResponse();
  31.      Result result = null;
  32.  
  33.      try
  34.      {
  35.         Parameters addOptions = getParametersInstance();
  36.         addOptions.add("object_id", "CONTACT");
  37.         String addFirstName = (String)params.get("addFirstName");
  38.  
  39.         String addLastName = (String)params.get("addLastName");
  40.  
  41.         if(addLastName != null && !addLastName.equals("") 
  42.               && addFirstName != null && !addFirstName.equals(""))
  43.         {
  44.             addOptions.add("first_name", addFirstName);
  45.  
  46.             addOptions.add("last_name", addLastName);
  47.         }
  48.         else
  49.         {
  50.            addOptions.add("first_name", "CPfirst"+new Date());
  51.            addOptions.add("last_name", "CPLast" + new Date());
  52.            addOptions.add("account_id", "1593373443");
  53.         } 
  54.         result = addRecord("CONTACT", addOptions);
  55.         debug("Message:" + result.getMessage());
  56.         cr.setData(result);
  57.         cr.setTargetPage("AddContact.jsp");
  58.       }
  59.       catch(Exception e)
  60.       {
  61.          cr.setTargetPage("AddContact.jsp");
  62.          cr.setMessage(e.getMessage());
  63.  
  64.          debug("Message:");          
  65.       }
  66.       return cr;
  67.     }
  68. }

Now the page is ready to be invoked from browser or web tab.


Pages in Lookup Fields

Lookup fields can be based on Pages, which display customized Lookup Windows. These pages are launched in the usual way, with the lookup File:lookupicon.gif icon, from within a record.

When a Lookup Window search is successful, these parameters are used to identify and return Lookup Fields in Pages:

Paramter Name Description
object_idObject Identifier
keywordString value, entered by the user in the lookup field.

If the user types ABC in the lookup field, then the keyword is ABC.

target_fieldUsed to store the Record Identifier
target_name_fieldUsed to store the contents of the field (text string format, contents of the field)
The Lookup Field is rendered using two HTML elements:
  • target_field
  • target_name_field
See the .jsp sample code files for more information.
Considerations


Lookup Examples

Search based on Lastname

This example performs a search action in a lookup window based on "Lastname" as the Record Identifier Field in Record Locator:

Add a Page:

  1. From the Account object, Add a Page
  2. Use this file name: AccountPopup.jsp
  3. Use this code sample: AccountPopup.jsp

Add a AccountPopup.java Class:

  1. From the Account object, Add a Class
  2. Use this file name: AccountPopup.java
  3. Use this code sample: AccountPopup.java

Add a AccountPopupController.java Class:

  1. From the Account object, Add a Class
  2. Use this file name: AccountPopupController.java
  3. Use this code sample: AccountPopupController.java


Search based on multiple fields

This example performs a search action in a lookup window using Multiple Fields in the Record Locator:

Prerequisite: In the Directory object, define the Record Identifier field to include "First name" and "Last name".


Add a Page
  1. From the Directory object, Add a Page
  2. Use this file name: DirectoryPopup.jsp
  3. Use this code sample: DirectoryPopup.jsp
Add a DirectoryPopup.java Class
  1. From the Directory object, Add a Class
  2. Use this file name: DirectoryPopup.java
  3. Use this code sample: DirectoryPopup.java
Add a DirectoryPopupController.java Class
  1. From the Directory object, Add a Class
  2. Use this file name: DirectoryPopupController.java
  3. Use this code sample: DirectoryPopupController.java


Multiple Fields in the Record Locator

If the Record Identifier Field in Record Locator is a combination fields, then the the Record Locator must be created by concatenating the field names.

For example, the record locator for the Employee object is a combination of First name, Last name. Then the record locator value is formed as: [First name value][space][-][space][Last name value]

First nameLast NameRecord Locator Value
John SmithJohn - Smith
Peter Peter -
Jones - Jones

Global Pages

ISVs and MSPs can create custom pages at global level for distribution to Tenants. This feature gives Service Providers the ability to design and build pages once, then make the custom work available to multiple tenants, as the default Home Page for Tenants, or added as Web Tabs.

Global Page access

Global Page access is defined by {namespace}, as shown in this URI:

http://{domainname}.com/networking/isv/{namespace}/{globalpage.jsp}
where:
{domainname} is the Service Domain of the Service Provider
{namespace} is the namespace of the Service Provider, defined in Company Information
{globalpage.jsp} is the the name of the Page


Considerations
  • Usage is hierarchical, meaning that:
  • ISVs can create Global Pages, which can be used by MSPs and Tenants of that ISV
  • MSPs can create Global Pages, which can be used by Tenants of that MSP

Create a Global Page

  1. Click Setup | Develop | Pages
  2. Click the [New Page] button, and complete the following information:
    Title
    Enter a title for the page, for example: pagename.jsp
    '.jsp' extension is required
    Display with Tab Header
    Checkbox
    Uncheck the Display with Tab Header option
  3. Enter the code in the text area
  4. Click the [Save] button to continue, or [Cancel] to stop the action

Using Global Pages

  • To use a Global Page as a Web Tab:
  1. Create a New Web Tab
  2. Choose URL as the Web Tab Type
  3. Paste the Global Page URI into the edit area:
    http://{domainname}.com/networking/isv/{namespace}/{globalpage.jsp}
    Remember to substitute actual values for the {arguments}
Personal tools
Categories