Short Portlet Programming Guide in P-Grade (Gridsphere) environment
description
Transcript of Short Portlet Programming Guide in P-Grade (Gridsphere) environment
![Page 1: Short Portlet Programming Guide in P-Grade (Gridsphere) environment](https://reader031.fdocuments.us/reader031/viewer/2022013101/56814020550346895dab7aeb/html5/thumbnails/1.jpg)
Short Portlet Programming Guide in P-Grade (Gridsphere)
environmentG. Hermann
![Page 2: Short Portlet Programming Guide in P-Grade (Gridsphere) environment](https://reader031.fdocuments.us/reader031/viewer/2022013101/56814020550346895dab7aeb/html5/thumbnails/2.jpg)
Content
• Main ideas
• Execution model
• Representation
• Part I Java – JSP collaboration
• Part II Definition of Portlets by portlet.xml and layout.xml
• Tomcat directory hierarchy
![Page 3: Short Portlet Programming Guide in P-Grade (Gridsphere) environment](https://reader031.fdocuments.us/reader031/viewer/2022013101/56814020550346895dab7aeb/html5/thumbnails/3.jpg)
Main ideas
• Layout design and business logic are separated
• Response WEB pages are generated with the help of run time compiled and linked java code.
• Even little parts of WEB pages can be handled independently (portlet concept)
![Page 4: Short Portlet Programming Guide in P-Grade (Gridsphere) environment](https://reader031.fdocuments.us/reader031/viewer/2022013101/56814020550346895dab7aeb/html5/thumbnails/4.jpg)
Warning !
• We restrict ourselves to the Portlet implementation of the Gridsphere
• Focus on the class ActionPortletTasks:– Defines “states” described by Java Servlet
Pages (Jsp)– Defines callback routines called
• before HTML response generation (view)• after user action (update)
![Page 5: Short Portlet Programming Guide in P-Grade (Gridsphere) environment](https://reader031.fdocuments.us/reader031/viewer/2022013101/56814020550346895dab7aeb/html5/thumbnails/5.jpg)
Execution model - possible ways
HTTML response generation
First request from client
init(PotletConfig) Y(ActionFormEvent)
X(RenderFormEvent)
Next requests from client
![Page 6: Short Portlet Programming Guide in P-Grade (Gridsphere) environment](https://reader031.fdocuments.us/reader031/viewer/2022013101/56814020550346895dab7aeb/html5/thumbnails/6.jpg)
Execution model-regime modify
HTTML response generation
First request from client
init(PotletConfig) Y(ActionFormEvent)
X(RenderFormEvent)
Next requests from client
![Page 7: Short Portlet Programming Guide in P-Grade (Gridsphere) environment](https://reader031.fdocuments.us/reader031/viewer/2022013101/56814020550346895dab7aeb/html5/thumbnails/7.jpg)
Execution model-regime show
HTTML response generation
First request from client
init(PotletConfig)
X(RenderFormEvent)
Next requests from client
![Page 8: Short Portlet Programming Guide in P-Grade (Gridsphere) environment](https://reader031.fdocuments.us/reader031/viewer/2022013101/56814020550346895dab7aeb/html5/thumbnails/8.jpg)
Representation I• java code (Action Portlet)
defines the callback routines and the current (and next) state made intuitive to the client by defining the selection of the proper Jsp page in that state. The java code is responsible for the whole business logic.
• Java Servlet Page (JSP) (file: xx.jsp) Composes the frame of the layout and defines communication interface between the client and java code in a given state.
• The UI Tag Library defines the layout and the passive –data- interface between java code and JSP. The Java representation of the UI Tag Library follows the Bean concept. The JSP representation of UI Tag Library is XML.
• “portlet.xml” defines the portlet and references the java code• “layout.xml” defines the menu hierarchy haw the callable portlets
should appear. (layout.xml is GridSphere specific!)
![Page 9: Short Portlet Programming Guide in P-Grade (Gridsphere) environment](https://reader031.fdocuments.us/reader031/viewer/2022013101/56814020550346895dab7aeb/html5/thumbnails/9.jpg)
Representation II
HTTML response generation
First request from client
init(PotletConfig) Y(ActionFormEvent)
X(RenderFormEvent)
Next requests from client
class Any extends ActionPortlet
Ani.jsp
UI Tag Library objects
![Page 10: Short Portlet Programming Guide in P-Grade (Gridsphere) environment](https://reader031.fdocuments.us/reader031/viewer/2022013101/56814020550346895dab7aeb/html5/thumbnails/10.jpg)
Remarks(1) UI TAG LIBRARY
• The UI Tag Library is not discussed in detailed in the subsequent example.
• The Java side usage of it is self explaining by the Bean paradigm.
• For the XML usage of it in the JSP file consult the document:http://www.gridsphere.org/gridsphere/docs/TagGuide/TagGuide.htm
• What you must know is that the interface variables are identified by associated Strings
![Page 11: Short Portlet Programming Guide in P-Grade (Gridsphere) environment](https://reader031.fdocuments.us/reader031/viewer/2022013101/56814020550346895dab7aeb/html5/thumbnails/11.jpg)
Remarks(2) State Transitions
Please note that the event handling interrupt routines of the Java Class ActionPortlet may terminate with the state transition instruction setNextState(PortletReqest,String), where the String parameter may refer either
– a name of a routine, or– a JSP. The action defined in that JSP defines the next
state.
![Page 12: Short Portlet Programming Guide in P-Grade (Gridsphere) environment](https://reader031.fdocuments.us/reader031/viewer/2022013101/56814020550346895dab7aeb/html5/thumbnails/12.jpg)
Remarks(3) other state subtilities
• The String “DEFAULT_HELP_PAGE” is used to define a JSP when the client hits the “?” icon on the portlet
• The String “DEFAULT_EDIT_PAGE” is used to define a JSP when client hits the “pen” edit icon.
![Page 13: Short Portlet Programming Guide in P-Grade (Gridsphere) environment](https://reader031.fdocuments.us/reader031/viewer/2022013101/56814020550346895dab7aeb/html5/thumbnails/13.jpg)
Remarks (4) Programing style
• The JSP pages may contain direct java code fragments among UI tags and forms.However you are emphatically asked to avoid them: The overview of the program logic can be lost easily if the program code is fragmented, and the JSP is not used as its designated: for gathering and rendering of client data.
![Page 14: Short Portlet Programming Guide in P-Grade (Gridsphere) environment](https://reader031.fdocuments.us/reader031/viewer/2022013101/56814020550346895dab7aeb/html5/thumbnails/14.jpg)
Part I: Life Cycle of a Portlet by an example
The simple Portlet “EnterName” redisplays a single string entered by the client.
![Page 15: Short Portlet Programming Guide in P-Grade (Gridsphere) environment](https://reader031.fdocuments.us/reader031/viewer/2022013101/56814020550346895dab7aeb/html5/thumbnails/15.jpg)
EnterName.java and the corresponding EnterName.jsp files
![Page 16: Short Portlet Programming Guide in P-Grade (Gridsphere) environment](https://reader031.fdocuments.us/reader031/viewer/2022013101/56814020550346895dab7aeb/html5/thumbnails/16.jpg)
First Request arrives from the client
HTTML response generation
First request from client
Init(PotletConfig) Y(ActionFormEvent)
X(RenderFormEvent)
Next requests from client
The routine init will be activated
![Page 17: Short Portlet Programming Guide in P-Grade (Gridsphere) environment](https://reader031.fdocuments.us/reader031/viewer/2022013101/56814020550346895dab7aeb/html5/thumbnails/17.jpg)
Java – Jsp connections-1DEFAULT_VIEW_PAGE determinesthat before the elaboration of the first response the given rendering routinewill be called.
![Page 18: Short Portlet Programming Guide in P-Grade (Gridsphere) environment](https://reader031.fdocuments.us/reader031/viewer/2022013101/56814020550346895dab7aeb/html5/thumbnails/18.jpg)
First Rendering
HTTML response generation
First request from client
Init(PotletConfig) Y(ActionFormEvent)
X(RenderFormEvent)
Next requests from client
Variables need to show to the client are prepared
![Page 19: Short Portlet Programming Guide in P-Grade (Gridsphere) environment](https://reader031.fdocuments.us/reader031/viewer/2022013101/56814020550346895dab7aeb/html5/thumbnails/19.jpg)
Java – Jsp connections-2The jsp is referenced by the java code.
After the running of the routine the HTML generation defined by the Jsp will be performed
![Page 20: Short Portlet Programming Guide in P-Grade (Gridsphere) environment](https://reader031.fdocuments.us/reader031/viewer/2022013101/56814020550346895dab7aeb/html5/thumbnails/20.jpg)
Java – Jsp connections-3
The parameter referenced by the handle “nameSessionHandle” does not exist, therefore the bean object referenced “nameOld” – wich will be created upon the first reference –receives the value “not defined”.
![Page 21: Short Portlet Programming Guide in P-Grade (Gridsphere) environment](https://reader031.fdocuments.us/reader031/viewer/2022013101/56814020550346895dab7aeb/html5/thumbnails/21.jpg)
Java – Jsp connections-4
The bean referenced as“nameOld” will be used to display the value known by the system before the user interaction.
![Page 22: Short Portlet Programming Guide in P-Grade (Gridsphere) environment](https://reader031.fdocuments.us/reader031/viewer/2022013101/56814020550346895dab7aeb/html5/thumbnails/22.jpg)
Java – Jsp connections-5
The jsp page will generate the HTML response
![Page 23: Short Portlet Programming Guide in P-Grade (Gridsphere) environment](https://reader031.fdocuments.us/reader031/viewer/2022013101/56814020550346895dab7aeb/html5/thumbnails/23.jpg)
HTML generated by the JSP as it appears for the Client
The Jsp page will generate the HTML code in the response for the selected frame
![Page 24: Short Portlet Programming Guide in P-Grade (Gridsphere) environment](https://reader031.fdocuments.us/reader031/viewer/2022013101/56814020550346895dab7aeb/html5/thumbnails/24.jpg)
Java – Jsp connections-6 The internally generated bean objects are used to exchange data between Jsp defined HTML code and Java routines
![Page 25: Short Portlet Programming Guide in P-Grade (Gridsphere) environment](https://reader031.fdocuments.us/reader031/viewer/2022013101/56814020550346895dab7aeb/html5/thumbnails/25.jpg)
Java – Jsp connections-7
The user hitting the button labeled as “Update” generates a Request activating the routine updateName
![Page 26: Short Portlet Programming Guide in P-Grade (Gridsphere) environment](https://reader031.fdocuments.us/reader031/viewer/2022013101/56814020550346895dab7aeb/html5/thumbnails/26.jpg)
Java – Jsp connections-8
Example: The Client fills the text field as “newValue”, and hits the Button “Update”
![Page 27: Short Portlet Programming Guide in P-Grade (Gridsphere) environment](https://reader031.fdocuments.us/reader031/viewer/2022013101/56814020550346895dab7aeb/html5/thumbnails/27.jpg)
Repeated request arrives
HTTML response generation
First request from client
Init(PotletConfig) Y(ActionFormEvent)
X(RenderFormEvent)
Next requests from client
The prescribed ActionFormEvent handler will be activated.
![Page 28: Short Portlet Programming Guide in P-Grade (Gridsphere) environment](https://reader031.fdocuments.us/reader031/viewer/2022013101/56814020550346895dab7aeb/html5/thumbnails/28.jpg)
Java – Jsp connections-9In the action event handler the value defined by the client and stored in a bean referenced as “nameNew” will be read
![Page 29: Short Portlet Programming Guide in P-Grade (Gridsphere) environment](https://reader031.fdocuments.us/reader031/viewer/2022013101/56814020550346895dab7aeb/html5/thumbnails/29.jpg)
Java – Jsp connections-10
The text value will be forwarded to the subsequent rendering routine via the handle “nameSessionHandle”
![Page 30: Short Portlet Programming Guide in P-Grade (Gridsphere) environment](https://reader031.fdocuments.us/reader031/viewer/2022013101/56814020550346895dab7aeb/html5/thumbnails/30.jpg)
Java – jsp connections
As a last step the routine triggers the rendering event
![Page 31: Short Portlet Programming Guide in P-Grade (Gridsphere) environment](https://reader031.fdocuments.us/reader031/viewer/2022013101/56814020550346895dab7aeb/html5/thumbnails/31.jpg)
Repeated Rendering
HTTML response generation
First request from client
Init(PotletConfig) Y(ActionFormEvent)
X(RenderFormEvent)
Next requests from client
![Page 32: Short Portlet Programming Guide in P-Grade (Gridsphere) environment](https://reader031.fdocuments.us/reader031/viewer/2022013101/56814020550346895dab7aeb/html5/thumbnails/32.jpg)
Java – Jsp connections-11
As the value associated by “nameSessionHandle” is not emptythe bean referenced as “nameOld”will receive this value
![Page 33: Short Portlet Programming Guide in P-Grade (Gridsphere) environment](https://reader031.fdocuments.us/reader031/viewer/2022013101/56814020550346895dab7aeb/html5/thumbnails/33.jpg)
HTML generated by the JSP as it appears for the Client after repeated Rendering
The bean referenced “nameOld” now has the value “newValue”
![Page 34: Short Portlet Programming Guide in P-Grade (Gridsphere) environment](https://reader031.fdocuments.us/reader031/viewer/2022013101/56814020550346895dab7aeb/html5/thumbnails/34.jpg)
Summary of all external Java- Jsp connections
![Page 35: Short Portlet Programming Guide in P-Grade (Gridsphere) environment](https://reader031.fdocuments.us/reader031/viewer/2022013101/56814020550346895dab7aeb/html5/thumbnails/35.jpg)
Part II Definition of a Portlet
• A new portlet prepared by the java and JSP files must have an entry in the file “portlet.xml” and it
• must be referenced in the file “layout.xml”,
• must define an interpreter java class path,
• And a title label
![Page 36: Short Portlet Programming Guide in P-Grade (Gridsphere) environment](https://reader031.fdocuments.us/reader031/viewer/2022013101/56814020550346895dab7aeb/html5/thumbnails/36.jpg)
portlet.xmlThe new potrlet Portlet name will
be referenced in file layout.xml
Text in the title of the portlet
Path of the java class controlling the portlet
![Page 37: Short Portlet Programming Guide in P-Grade (Gridsphere) environment](https://reader031.fdocuments.us/reader031/viewer/2022013101/56814020550346895dab7aeb/html5/thumbnails/37.jpg)
The layout.xml
• Must define the menu hierarchy
• Define the appropriate labels for the user navigation
• Reference the used portlets
![Page 38: Short Portlet Programming Guide in P-Grade (Gridsphere) environment](https://reader031.fdocuments.us/reader031/viewer/2022013101/56814020550346895dab7aeb/html5/thumbnails/38.jpg)
layout.xml
Portlet as a submenu
item
Display name of a group of a submenu
Display name of of a submenu
item
Referencing the name of the potled defined in portlet.xml
Referencing the web application
![Page 39: Short Portlet Programming Guide in P-Grade (Gridsphere) environment](https://reader031.fdocuments.us/reader031/viewer/2022013101/56814020550346895dab7aeb/html5/thumbnails/39.jpg)
Summary of connectons: layout.xml, portlet.xml and HTML image
![Page 40: Short Portlet Programming Guide in P-Grade (Gridsphere) environment](https://reader031.fdocuments.us/reader031/viewer/2022013101/56814020550346895dab7aeb/html5/thumbnails/40.jpg)
webapps/
…/
…/
jsp/
…/
WEB-INF/
…/
portal30/…/
…/hello/…/
…/
enterName.jsp
…jsp
…jsp
lib/
classes/
…/
portlet.xml
layout.xml
hu/
sztaki/
lpds/
pgportal/
portlets/
hello/EnterName.class
Tomcat dictionary
The jar files encountered here must correspond to the import references defined in
EnterName.java