Sometimes you need a plug-in with more functionality than the Plug-In Studio can provide. In this situation you can use the Plug-In Studio to build most of the user interface needed, then add additional features by writing custom Java code.
The following code shows how to customize a task:
public class MyCustomTask extends eDirAccessService { protected boolean preRead(TaskContext context, Properties resultStrings) { // do work here return true; } protected boolean postRead(TaskContext context, Properties resultStrings) { // do work here return true; } protected boolean preWrite(TaskContext context, Properties resultStrings) { // do work here return true; } protected boolean postWrite(TaskContext context, Properties resultStrings) { // do work here return true; } }
To customize a page, use the following example:
public MyCustomPage extends DirPropertyBookPage { public void cache(PropertyPageContext context) throws PageException { // work here save(context, context.getResultStrings()); // or work here } public void show(PropertyPageContext context) throws PageException { show(context, context.getResultStrings()); } }
After your Java code is compiled and placed in the classpath (in the classes directory or in the lib directory in a JAR file), you must update the plug-in to point to your Java class instead of the default one that the Plug-in Studio assigns. For a task, this is done by modifying the rbsTask object in eDirectory. Change the entry point attribute to the fully qualified name of your class. For a property page, edit the plug-in XML file in the custom/plug-ins directory. Change the entry-point element to the fully qualified class name.
It is possible to dynamically fill a drop-down list for plug-ins developed with Plug-in Studio, and other custom plug-ins. However, it is not possible to do this for base content plug-ins. The following example shows one way this can be done:
In your task, include Java code such as the following:
properties.put("Sch_ClassList.count" , size);
for (int i=0; i<size; i++)
{
properties.put("Sch_ClassList.name." + i, str[0]);
}
Then, in the JSP file you could display the dynamic dropdown list as follows:
<td>
<select name="AvailableClasses" size=10 style="WIDTH: 340px" >
<% c.set("i", "0");
while (c.lt(c.var("i"), c.var("Sch_ClassList.count")))
{ %>
<option value="<%= c.var("Sch_ClassList.name."+c.var("i")) %>
<% c.inc("i");
} %>
</select>
</td>
The Plug-In Studio creates JSPs in webapps/nps/portal/modules/custom/skins/default/devices/default.