Portlet Factory, Version 6.1.2
Method builder
The Method builder adds a Java method to the WebApp.
Use this builder when you want to use some Java code in your Model.
When you regenerate or save the model, the IBM® WebSphere Portlet Factory servlet creates a Java class that includes all of the Method builder calls in the model. When you run the model, the WebSphere Portlet Factory servlet instantiates an object of the generated class and calls the methods on that generated object.
Use the Method builder to do the following:
- Allow the method inputs or body to be profiled.
- Make simple calls to display pages, call methods, or execute service calls.
For larger, more complex methods, you should create a Java class and the methods in a Java editor and add a Linked Java Object (LJO) builder call to your model that refers to that Java class.
Quick tips
- Double-check your Java syntax in an IDE
- If you are writing an involved method, or are unsure if your syntax will compile, copy the syntax for the method into a temporary test Java source file in your IDE and try compiling the temporary test class.
- Profiling method builder call inputs
- When you profile the inputs to a Method builder call, the WebSphere Portlet Factory servlet generates a separate class file to the WEB-INF/work/source/genjava directory for each profile-specific implementation of the method. For example, if you profiled the Body input to the Method builder call and set the value for the body text for two profiles, the WebSphere Portlet Factory servlet generates two Java source files in the WEB-INF/work/source/genjava directory: ModelName_Profile1.java and ModelName_Profile2.java.
- Importing classes
- The following guidelines describe the Method builder's behavior with regard to importing classes:
- If the method requires imports and you do not specify the classes needed in the method's Imports List value, the Java code will not compile.
- If you add the correct classes to import, the Java code will recompile and succeed.
- If the method's Imports List value is removed or modified in any way, this change is not picked up.
As a result, even though the new method code does not compile, the method appears to succeed because the generated class is cached.
Parent topic: Builder help
- About using the builder call editor
The builder call editor allows you to specify all the input values to a builder call.
- Method builder inputs
This topic describes the inputs for the Method builder.
- Writing methods
Methods do the work of processing form inputs, executing other parts of the web applications (even other web applications), and performing any other logic that the WebApp requires to function the way you want it to.
- Executing model actions
This information describes how to execute model actions.
- Processing form submissions
LJO Methods and Method builder calls access inputs submitted by FORM POST or URL query parameters, by the RequestInputs interface, or direct arguments to the method.
- Interacting with the session object
You can store objects in the session by setting attributes on the session and specifying the value for those attributes as the objects that you want to share between models.
- Generating URLs to model actions
You can generate the URL for actions in the current model or in another model.
- Getting system properties
You can get the values of IBM WebSphere Portlet Factory properties stored in the cluster.properties and bowstreet.properties files.
- Getting and setting variable values
You can access all of the variables in the web application by calling the webAppAccess.getVariables() method.
- About getting data from the request
You can access the HttpServletRequest object by calling the webAppAccess.getHttpServletRequest() method.
- Modifying the response
Use the HttpServletResponse object to modify the content type of the data returned by a method.
- Overview: working with XML
When you develop J2EE applications with IBM WebSphere Portlet Factory, much of the underlying technology relies on XML.
- Retrieving multiple input values from a Checkbox Group builder
You can retrieve multiple input values from a Checkbox Group builder for use in a model by creating a iterator in the Method builder.
Library | Support |