JSF Custom Grid Tags Mehmet Nacar Tallahassee, FL March, 2006 Optional JSF Background Material.

Download Report

Transcript JSF Custom Grid Tags Mehmet Nacar Tallahassee, FL March, 2006 Optional JSF Background Material.

JSF Custom Grid Tags
Mehmet Nacar
Tallahassee, FL
March, 2006
Optional JSF
Background Material
Standard JSF Validators

required attribute checks if the input
text is empty.
<h:inputText id="username“ required="true“ value="#{resource.username}“ />
<h:message id="junk1" for="username“ showDetail="true"
errorStyle="color:red"/>
There are also validator methods to check format of the value
Also there values to look up the property validity.
How do you write custom validators? How do you use them in the
JSF page/bean code? Where do they go in the code base? What
validators does VLab need? Where do they go? This is more of a
discussion topic. --Marlon
Standard Navigation


Navigation among JSF pages
provided by faces-config.xml
Navigation rules defined like below.
<navigation-rule>
<from-view-id>/upload/gFTP.jsp</from-view-id>
<navigation-case>
<from-outcome>proxy</from-outcome>
<to-view-id>/upload/gftpProxy.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/upload/fileList.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>link</from-outcome>
<to-view-id>/upload/junk.jsp</to-view-id>
</navigation-case>
</navigation-rule>
Managed Beans



All beans has own specific property values.
There are also common properties among the
beans.
submitAction() method is common for all beans.
• Returns “success” value that controls navigation.

error and errorStatus properties are also common
for all beans.
• <h:outputText value="#{taskgraph.error}"
rendered="#{taskgraph.errorStatus}" style="color:red"
/>

Error properties catch exceptions and
display message summary to the user.
Beans in faces-config.xml






managed-bean>
<description>Context Bean is for context
tags</description>
<managed-beanname>context</managed-bean-name>
<managed-beanclass>ogce.gsf.context.ContextBean</ma
naged-bean-class>
<managed-beanscope>session</managed-bean-scope>
</managed-bean>
JSF Extensions for
VLAB
Basic Idea for Grid Service Clients


We write JSF tag libraries wrap calls to the
Java CoG kit.
This simplifies association of page events
(button clicks, link clicks) with composite
Grid actions.
• And increase reuse of code.

For documentation of the COG Abstraction
API and some programming examples, see
http://wiki.cogkit.org/index.php/Java_CoG
_Kit_Abstraction_Guide
Custom Tags

task
• Creates and submits grid tasks

taskgraph
• Creates and submits grid taskgraphs as Directed Acyclic Graph
(DAG)
• That is, describes composite, multistep actions

taskAdd
• Sub component for taskgraph. Adds dependency

proxy
• Gets and manage proxies from Myproxy server

storeContext
• Stores job information to ws-context server.

upload
• Provides upload capability to JSF (Browser to portal server)
JSF Grid Beans

Package ogce.gsf has the following:
• ResourceBean: loads properties from
resources.properties
• ProxyManagerBean: stores the Grid credential.
• TaskBean: simple job submission
• TaskGraphBean: creates composite task submissions
• FactoryBean: manages multiple TaskBean and
TaskGraphBean instances for a single user
• GridFTPManagerBean: file operations and file browsing
• ContextBean: client to the WS-Context server, provides
context browsing.

Described in more detail below.
Managed Beans (Again)



All beans has own specific property values.
There are also common properties among the
beans.
submitAction() method is common for all beans.
• Returns “success” value that controls navigation.

error and errorStatus properties are also common
for all beans.
• <h:outputText value="#{taskgraph.error}"
rendered="#{taskgraph.errorStatus}" style="color:red"
/>

Error properties catch exceptions and
display message summary to the user.
Resource Bean

Resource bean works with resource bundles.
•
•
•
•
resource.properties should be on the classpath.
For webapps its path is WEB-INF/classes
For jars its path is the parent directory.
The following are example properties with associated get/set
methods.
hostname = gf1.ucs.indiana.edu
provider = GT2
taskname = test
executable = PWSCF/pwscf
#arguments = 120
stdin = /tmp/pwscf_input
stdout = /tmp/out
source = gridftp://gf1.ucs.indiana.edu/home/manacar/altix
target = gridftp://gf1.ucs.indiana.edu/home/manacar/out
contextURI = /tmp/vlab/manacar
username = manacar
portNumber = 7512
Proxy Manager Bean




Gets proxy from myproxy server.
Stores the proxy into session, since proxy
is sharable among portlets.
Its parameters taken by resource bean.
Action method of proxy bean is
authenticate.
<h:commandButton id="submit“ action="#{ProxyManagerBean.authenticate}“
value="GetProxy"/>
Task Bean




Major task unit of Java COG abstractions.
Corresponds to GRAM job submissions.
Gets input parameters, prepares task and submit it.
Works with Factory Bean.
• Factory Bean manages multiple instances for a single user.
• Each Factory Bean associated with Cookie/Session, so Tomcat
and JSF manage Factory Beans for different users







So we only have to worry about multiple beans owned by same
user.
Tomcat distinguishes different users for us.
All submitted tasks stored in the factory.
TaskBean implements StatusListener to report status
changes
<o:task id="task1" method="#{task.create}"
type="FileTransferInput" />
<o:task id="task2" method="#{task.create}" type="JobSubmit"
/>
<o:task id="task3" method="#{task.create}"
type="FileTransferOutput" />
Task Submission Form
Corresponding JSF snippets
<o:taskGraph id="myGraph" method="#{taskgraph.test}" >
<o:task id="task1" method="task.create" type="FileTransfer" />
<o:task id="task2" method="task.create" type="JobSubmit" />
<o:task id="task3" method="task.create" type="FileTransfer" />
<o:taskAdd name="task1" method="taskgraph.add" />
<o:taskAdd name="task2" depends="task1" method="taskgraph.add" />
<o:taskAdd name="task3" depends="task2" method="taskgraph.add" />
</o:taskGraph>
<h:panelGrid columns="3" >
<h:outputText value="Hostname (*) "/>
<h:inputText value="#{task.hostname}"/>
</h:panelGrid>
<h:panelGrid columns="3" >
<h:outputText value="Provider (*) "/>
<h:inputText value="#{task.provider}"/>
</h:panelGrid>
<h:panelGrid columns="2">
<h:commandButton id="submit" value="Submit" action="#{taskgraph.submitAction}"/>
<h:commandButton value="Clear" type="Reset"/>
</h:panelGrid>
Task Monitoring with JSF
Data Model
Corresponding Java class.
public class Job {
private String jobId;
private String status;
private String submitDate;
private String finishDate;
}
<h:dataTable value="#{jobData.jobs}" var="job">
<h:column>
<f:facet name="header">
<h:outputText style="font-weight: bold" value="Job ID" />
</f:facet>
<h:outputText value="#{job.jobId}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText style="font-weight: bold" value="Submit Date"
/>
</f:facet>
<h:outputText value="#{job.submitDate}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText style="font-weight: bold" value="Finish Date"
/>
</f:facet>
<h:outputText value="#{job.finishDate}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText style="font-weight: bold" value="Status" />
</f:facet>
<h:outputText value="#{job.status}"/>
</h:column>
</h:dataTable>
Factory Bean

Controls bean creations and listeners.
• Clones beans and stores bean instances in the session.

Factory Bean contain three hashmaps to store task
features.
• Beans (TaskBean)
• Graphs (TaskGraph)
• Listeners (for both)

Java COG listeners propagates status changes to listeners
and beans.
• status, finishDate properties changes accordingly.




Monitoring actions are called by Factory Bean
Factory Bean initiates stores data to JobData object that
shown by JSF page
JobData has List to in data table.
Action methods
• monitorAction() is for task bean
• monitorGraph() is for taskgraph bean
TaskGraph Bean



TaskGraph Bean manages a workflow of tasks.
It creates composite tasks using DAG.
User has to define tasks and their dependency.
• Otherwise tasks runs independently.


TaskGraph can compose sub taskgraphs.
TaskGraph Bean has two internal Java COG object.
• Taskgraph object: defines taskgraph spec and paramaters.
• Handler object: works with StatusListener to get status
changes.

TaskGraphBean has to implement StatusListener to report
status changes
GridFTPManagerBean


Provides file browsing, download, upload and file removing.
Establish a gridftp connection
<h:commandButton id="submit" value="Submit"
action="#{gftp.getConnection}"/>

Browse files with doList()
doList() loads filelist. It is an internal method called by getConnection()

Delete files with delete()
<h:commandButton value="Delete" action="#{gftp.delete}"
actionListener="#{gftp.filename}">
<f:param id="finame" name="fname" value="#{file}"/>
</h:commandButton>

Download files with download()
<h:commandLink value="" action="#{gftp.download}"
actionListener="#{gftp.filename}">
<h:graphicImage value="#{file.piclink}"/>
<f:param id="fname" name="fname" value="#{file}"/>
</h:commandLink>
ContextBean


ContextBean provides navigation on wscontext server.
Session keys of context server are like
below.
• vlab://tmp/manacar/task1/timestamp
• This is just a URI structured name convention



vlab://tmp/ is the root for all
Each user’s personal context follows.
Similar to linux directory structure. (Base
directory like below.)
• vlab://tmp/manacar/blah/blah2/blah3

More detail later.
Grid Faces Tags


All of the beans shown previously can be used in conventional
standalone JSF way.
They are also associated with custom JSF tag extensions we
developed:
• <o:task/>, <o:taskGraph/>, <o:taskAdd/> and <o:contextStore/>

Purpose is to define composite actions that are associated with
submit button clicks, etc.
• That is, commandButton and commandLink

Taskgraph is parent tag and the others are child tags.
<f:verbatim>
<o:taskGraph id="myGraph" method="#{taskgraph.test}" binding="#{taskgraph.taskgr}" >
<o:task id="task1" method="#{task.create}" type="FileTransferInput" />
<o:task id="task2" method="#{task.create}" type="JobSubmit" />
<o:task id="task3" method="#{task.create}" type="FileTransferOutput" />
<o:taskAdd id="taskadd1" name="task1" depends="task2" method="taskgraph.add" />
<o:taskAdd id="taskadd1" name="task2" depends="task3" method="taskgraph.add" />
<o:contextStore id="context" type="store" method="none" />
</o:taskGraph>
</f:verbatim>
Importing GSF Taglibs

Taglibs are defined in tld files.
<tag>
<name>taskGraph</name>
<tag-class>ogce.gsf.tags.TaskGraphTag</tag-class>
<body-content>JSP</body-content>
<attribute>
<name>id</name>
</attribute>
<attribute>
<name>method</name>
</attribute>
<attribute>
<name>binding</name>
</attribute>
</tag>
• Corresponding components defined in faces-config.xml
<component>
<description>Taskgraph component</description>
<component-type>taskGraph</component-type>
<component-class>ogce.gsf.tags.UITaskGraph</component-class>
</component>
Using WS-Context
WS-Context

A context is a nugget of information with an associated name.
• You can read/write contexts.
• You can store arbitrary byte arrays--but for VLAB we typically store
strings


WS-Context server provides database access wrapped with web
services.
We’ve developed smart clients to store contexts like unix file
system.
• Normally contexts are flat, associated only with UUID, not structured
• We added the structure to use file system tree-like structure.

Basically there two concepts in WS-Context.
• Session keys (URI) are (hopefully) human comprehensible names.

vlab://tmp/manacar/12506-041932/tr/
• Context keys (uuid) define the unique system name of the context.




uuid:0A556090-7464-11DA-ABF3-E30096A3A69A-1135418397994
Session keys to store branches (directories)
Context keys to store contexts (files)
A session can contain one or more session and contexts
WS-Context II

Storing information to context store is done by several beans.
• TaskGraph Bean creates a unique context URI for each job submission
• TaskListener stores changing values on runtime like status, finishDate
• Hpsearch stores output file location on remote site (needed for
vizualization).


VLab monitoring pages involves context reading and browsing.
Browsing page takes user home directory on context service and
allow users to navigate on their workspace.
<user-attribute>
<description>User Name</description>
<name>user.name</name>
</user-attribute>

Only storing to context is tagged by taglibs.
• <o:contextStore id="context" type="store" method="none" />

Context browsing is done by associated JSF pages and data tables
• ContextListBean
• Context Attributes
Reading Context in JSF
<h:outputText value="Context Name "/>
<h:outputText value="#{context.contextName}" />
<h:outputText value="Context Value "/>
<h:outputText value="#{context.contextValue}" />
<h:outputText value="Context Status "/>
<h:outputText value="#{context.contextStatus}" />
<h:commandButton value="New Job Submit with Context
Values“ action="#{context.contextAction}"/>
Browsing on context


Context browsing provided by navigate(String parent)
method.
Portlet gets user.name property and builds up user’s
context
• vlab://tmp is root context for vlab portal
• User manacar will have context



vlab://tmp/manacar
When reach to leaf node, It can access to contexts in it.
For example, vlab://tmp/manacar/task1/timestamp
•
•
•
•
•
•
•
•
•
There are certain context in this location listed below.
Resource bean properties (with taskname)
Status context
SubmitDate context
FinishDate context
Input file location
Output file location
FSU location (transferring output file for viz. process)
Etc.
Using the Context Navigation
<h:dataTable value="#{contextlist.contexts}" var="ctx">
<h:column>
<f:facet name="header">
<h:outputText style="font-weight: bold" value="Icon" />
</f:facet>
<h:commandLink value="" action="#{context.navigate}"
actionListener="#{context.contextName}">
<h:graphicImage value="#{ctx.piclink}"/>
<f:param id="cname" name="cname" value="#{ctx}"/>
</h:commandLink>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText style="font-weight: bold" value="Context Name" />
</f:facet>
<h:outputText value="#{ctx.name}"/>
</h:column>
</h:dataTable>
Reading from context


Methods from ContextBean
navigate()
• Main method of context navigation
• Prepares contextList to being display by
navigation JSF page.




getSessionDirectoryInfo(String parent)
getContextFromLeafSession(Vector
session_info)
wipeOut(String user_session_key)
wipeOut(“%") deletes all sessions.
Storing to context




Context store tag wraps Context Bean
storeContext method as taglib.
ContextBean wraps context API with JSF pages.
ContextPublishClient is base API for ws-context
smart client.
3 methods to save a context
• SessionInfo[] find_session(String user_identifier,
String qualifier)
• URI find_session_key(String identifier, String
qualifier)
• ContextDetail saveContext(String user_identifier,
URI session_key, byte [] context_byte_array)
properties.properties
#####################################################################
###
#
# FTHPIS - Property file used to set parameters for UDDI-Extended
# Information Service
# Web Site: http://grids.ucs.indiana.edu/~maktas/fthpis/index.html
#
#####################################################################
####
#####################################################################
####
#
# Userid/passwords should not generally be stored in clear text
#
#####################################################################
####
cgl.fthpis.jdbcUser = uddi_user
cgl.fthpis.jdbcPassword = changeIt
#####################################################################
####
#
# The WSDL address for the inquiry and publishing API of the target
# UDDI-Extended Information Service
#
#####################################################################
####
#UDDI_Extended_WSDL = http://localhost:8080/uddi_wscontext/services/UDDI_Extended
#UDDI_WSContext_WSDL = http://localhost:8080/uddi_wscontext/services/UDDI_WSContext
UDDI_Extended_WSDL = http://gf8.ucs.indiana.edu:4647/uddi_wscontext/services/UDDI_Extended
UDDI_WSContext_WSDL = http://gf8.ucs.indiana.edu:4647/uddi_wscontext/services/UDDI_WSContext
#####################################################################
###########
# NB Parameters. Please replace following NB parameters to point to your
# Narada Broker
#####################################################################
###########
hostname = gf8.ucs.indiana.edu
portnum = 4648
These are properties
in the client’s
uuid_wscontext_beta.
jar.
You will need to
change if you ever
need to contact
another server.
To Do: needs to be
taken out and added
to project.properties
of the portal maven
build.
Ws-Context
jars





Jar conflicts can
lead to problems.
Axis.jar is a known
offender.







Context monitoring


Hpsearch


NaradaBrokering.jar
activation.jar
axis-ant.jar
axis.jar
commons-discovery.jar
commons-logging.jar
jaxrpc.jar
jsp-api.jar
jug-uuid.jar
junit.jar
mail.jar
saaj.jar
servlet-api.jar
uddi_wscontext_beta.jar
wscontext.0_wtimestam
p.jar
wsdl4j.jar
JSF Portlets for
GridSphere: Some
Supplemental Slides
Mehmet Nacar
GridSphere 2.x



Deployment on Gridsphere requires some additional
configuration.
Make sure CATALINA_HOME set.
GridSphere normally runs in Tomcat 5.0.2x. If you want to
run in Tomcat 5.5.x, you should
• a) install Tomcat 5.5's java 1.4.2 compatibility package as
instructed above, and
• b) copy ant.jar and ant-launcher.jar from Tomcat 5.0.2x's
common/lib directory into 5.5.x's common/lib.

Also edit the tomcat-users.xml file in the jakarta-tomcat5.5.x/conf directory to add the following role and user:
• <?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="manager"/>
<user username="gridsphere" password="gridsphere"
roles="manager"/>
</tomcat-users>
JSF Sample Portlet


Sample portlet is the Sun provided guessNumber portlet
example available from the JSF source code distribution. It
is packaged to work inside the GridSphere container.
Instructions:
• Set gridsphere environment variable


gridsphere.home=/home/manacar/gridsphere-2.0.2
gridsphere.build=/home/manacar/gridsphere-2.0.2/build
• ‘ant install’ makes it work on Gridsphere


To work with Tomcat 5.5.x, all commons jar files from Tomcat 5.0.2x
should be added to common/lib. Otherwise JSFportlets doesn’t work.
Move the following jar files from $CATALINA_HOME/server/lib to
$CATALINA_HOME/common/lib: (It is for only Tomcat 5.0.2x)
•
•

commons-beanutils.jar
commons-digester.jar
After deploying, start up GridSphere and create a group from Admin>Groups with the "guessNumber" portlet in it. Then add yourself to the
group. if you don’t use predefined groups and tabs. (optional group.xml,
layout.xml setup files)
Gridsphere portlets

GridSphere portlet apps use the
following files:
• web.xml (required) - specifies GS
portlet loader servlet
• gridsphere-portlet.xml (required) specifies GS portlet loader portlet
• portlet.xml (required) - a portlet
descriptor
• (optional) group.xml - a group
descriptor
• (optional) layout.xml - a layout
associated with the group
MyproxyManager Portlet


The following steps for developing a JSF portlet:
Place source code into /src directory
• ~/jsfMyproxyManager/src/proxymanager

Place JSP files into /webapp directory
• ~/jsfMyproxyManager/webapp

Place config files into /webapp/WEB-INF
• ~/jsfMyproxyManager/webapp/WEB-INF

Place required jars into /lib/ext
• ~/jsfMyproxyManager/lib






jsf-api.jar
jsf-portlet.jar
proxymanager-api-3-3.0.jar
jsf-impl.jar
jstl.jar
standard.jar
web.xml
web.xml
<web-app>
<display-name>JSF Proxy portlets</display-name>
<description>
Provides JSF Proxy portlets
</description>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<param-name>javax.faces.application.CONFIG_FILES</param-name>
<param-value>/WEB-INF/faces-config.xml</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.portlet.INIT_VIEW</param-name>
<param-value>/ProxyManager.jsp</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.validateXml</param-name>
<param-value>true</param-value>
</context-param>
web.xml II
<!-- Faces Servlet -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup> 1 </load-on-startup>
</servlet>
<servlet>
<servlet-name>PortletServlet</servlet-name>
<servlet-class>org.gridlab.gridsphere.provider.portlet.jsr.PortletServle
t</servlet-class>
</servlet>
<!-- Faces Servlet Mapping -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/myproxy/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>PortletServlet</servlet-name>
<url-pattern>/jsr/jsfMyproxyManager</url-pattern>
</servlet-mapping>
</web-app>
faces-config.xml
<faces-config>
<application>
<locale-config>
<default-locale>en</default-locale>
<supported-locale>de</supported-locale>
<supported-locale>fr</supported-locale>
<supported-locale>es</supported-locale>
</locale-config>
</application>
<navigation-rule>
<description>
The decision rule used by the NavigationHandler to
determine which view must be displayed after the
current view, greeting.jsp is processed.
</description>
<from-view-id>/ProxyManager.jsp</from-view-id>
<navigation-case>
<description>
Indicates to the NavigationHandler that the response.jsp
view must be displayed if the Action referenced by a
UICommand component on the greeting.jsp view returns
the outcome "success".
</description>
<from-outcome>success</from-outcome>
<to-view-id>/GetProxy.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<description>
The decision rules used by the NavigationHandler to
determine which view must be displayed after the
current view, response.jsp is processed.
</description>
<from-view-id>/GetProxy.jsp</from-view-id>
<navigation-case>
<description>
Indicates to the NavigationHandler that the greeting.jsp
view must be displayed if the Action referenced by a
UICommand component on the response.jsp view returns
the outcome "success".
</description>
<from-outcome>success</from-outcome>
<to-view-id>/ViewAndDispose.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<description>
The decision rules used by the NavigationHandler to
determine which view must be displayed after the
current view, response.jsp is processed.
</description>
<from-view-id>/ViewAndDispose.jsp</from-view-id>
<navigation-case>
<description>
Indicates to the NavigationHandler that the greeting.jsp
view must be displayed if the Action referenced by a
UICommand component on the response.jsp view returns
the outcome "success".
</description>
<from-outcome>success</from-outcome>
<to-view-id>/ProxyManager.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<managed-bean>
<description>
The "backing file" bean that backs up the guessNumber webapp
</description>
<managed-bean-name>MyProxyBean</managed-bean-name>
<managed-bean-class>proxymanager.MyProxyBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
</faces-config>
portlet.xml
<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd" vers
ion="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocati
on="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/x
ml/ns/portlet/portlet-app_1_0.xsd">
<portlet>
<description>JSF MyProxy Portlet</description>
<portlet-name>myproxyManager</portlet-name>
<display-name>JSF MyProxy Portlet</display-name>
<portlet-class>com.sun.faces.portlet.FacesPortlet</portlet-class>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>VIEW</portlet-mode>
</supports>
<portlet-info>
<title>MyProxy Portlet</title>
<short-title>myproxy</short-title>
</portlet-info>
</portlet>
</portlet-app>
group.xml
<?xml version="1.0" encoding="UTF-8"?>
<portlet-group>
<group-name>jsfMyproxyManager</group-name>
<group-description>JSF MyProxy portlets</groupdescription>
<group-visibility>PUBLIC</group-visibility>
<portlet-role-info>
<portletclass>jsfMyproxyManager#myproxyManager</portletclass>
<required-role>USER</required-role>
</portlet-role-info>
</portlet-group>
layout.xml
<portlet-tabbed-pane>
<portlet-tab label="JSF MyProxy Manager">
<title lang="en">JSF MyProxy Manager</title>
<portlet-tabbed-pane style="sub-menu">
<portlet-tab label="myproxyManager">
<title lang="en">MyProxy Portlet</title>
<table-layout>
<row-layout>
<column-layout>
<portlet-frame label="proxyPF">
<portlet-class>jsfMyproxyManager#myproxyManager
</portlet-class>
</portlet-frame>
</column-layout>
</row-layout>
</table-layout>
</portlet-tab>
</portlet-tabbed-pane>
</portlet-tab>
</portlet-tabbed-pane>
gridsphere-portlet.xml
<portlet-app-collection>
<portlet-app-def>
<portlet-app id="org.gridlab.gridsphere.provider.portlet.jsr.PortletServlet">
<portlet-name>JSR Portlet Servlet</portlet-name>
<servlet-name>PortletServlet</servlet-name>
</portlet-app>
<concrete-portlet-app id="org.gridlab.gridsphere.provider.portlet.jsr.PortletSer
vlet.1">
<concrete-portlet>
<portlet-name>Portlet Servlet</portlet-name>
<default-locale>en</default-locale>
<language locale="en">
<title>Portlet Servlet</title>
<title-short>Portlet Servlet</title-short>
<description>A JSR Portlet Loader</description>
<keywords>portlet servlet</keywords>
</language>
</concrete-portlet>
</concrete-portlet-app>
</portlet-app-def>
</portlet-app-collection>
Managed Beans

The most important features of a
bean is are the properties that it
exposes. A property is any attribute
of the bean that has
• a name
• a type (type should be a Java Object)
• methods for getting and/or setting the
property value
MyProxyBean
public class MyProxyBean {
private int SECS_PER_MIN = 60;
private int SECS_PER_HOUR = 3600;
private GSSCredential proxyCred=null;
String userName = null;
String hostName = null;
String passPhrase = null;
String proxyView = null;
Integer lifetime = null;
Integer portNumber = null;
public MyProxyBean() {
}
….
}
….
….
GetProxy.jsp
<HTML>
<HEAD> <title>Proxy Fetching Example</title> </HEAD>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<body bgcolor="white">
<f:view>
<h:form id="entryForm" >
<h3>Fill out the form to get your proxy credential</h3>
<h:panelGrid columns="3">
<h:outputLabel for="userSt">
<h:outputText value="User Name:"/>
</h:outputLabel>
<h:inputText id="userSt"
required="true"
value="#{MyProxyBean.userName}">
</h:inputText>
<h:message id="junk1" for="userSt"
showDetail="true"
errorStyle="color:red"/>
<h:outputLabel for="submit">
<h:outputText value="Get Credential:"/>
</h:outputLabel>
<h:commandButton id="submit"
action="#{MyProxyBean.authenticate}"
value="GetProxy"/>
</h:panelGrid>
</h:form>
</f:view>
</body>
</HTML>
Standard JSF navigation rules
Make sure MyProxyBean.authenticate returns a value “success” to match
with navigation
<navigation-rule>
<description>
The decision rule used by the NavigationHandler to
determine which view must be displayed after the
current view, greeting.jsp is processed.
</description>
<from-view-id>/ProxyManager.jsp</from-view-id>
<navigation-case>
<description>
Indicates to the NavigationHandler that the response.jsp
view must be displayed if the Action referenced by a
UICommand component on the greeting.jsp view returns
the outcome "success".
</description>
<from-outcome>success</from-outcome>
<to-view-id>/GetProxy.jsp</to-view-id>
</navigation-case>
</navigation-rule>

Getting Session








PortletSession gets session in the bean
It’s allowed to store session to ProxyStore.
FacesContext facesContext =
FacesContext.getCurrentInstance();
PortletSession portletSession = (PortletSession)
facesContext.getExternalContext().getSession(fal
se);
try {
ProxyManager.addProxy(portletSession,
proxyCred);
GSSCredential proxy = (GSSCredential)
ProxyManager.getDefaultProxy(portletSession);
} catch(Exception ex) { }