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.
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:
Method builder inputs: wpf7
- 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.
This topic describes the inputs for the Method builder.
Parent topic: Builder Reference: wpf7
About using the builder call editor: wpf7
Writing methods: wpf7
Executing model actions: wpf7
Processing form submissions: wpf7
Interacting with the session object: wpf7
About getting data from the request: wpf7
Modifying the response: wpf7
Generating URLs to model actions: wpf7
Getting system properties: wpf7
Getting and setting variable values: wpf7
Retrieving multiple input values from a Checkbox Group builder: wpf7