Reputation: 5299
Hi guys can you tell me about URL in portlets. For example if i have myPortlet.java
what i gonna do to call it from html form? I have to write line
<portlet-class>test.myPortlet</portlet-class>
in portlet.xml
.
Im understand that in form i gonna use actionURL
but how to build it?
Another question: Another java classes calls in portlet like in servlet?
Upvotes: 1
Views: 657
Reputation: 5291
Depending on what do you want your portlet to do, you may use different URLs:
processAction()
method (thus change the state of your portlet), use the action URL. In a JSP included to your portlet's view you can obtain it by calling <portlet:actionURL />
. In portlet code, one can get the URL by calling RenderResponse.createActionURL()
<portlet:renderURL/>
. This will trigger a render of the portlet. Java API alternative is to call RenderResponse.createRenderURL()
<portlet:resourceURL />
tag to get a URL that triggers a call to serverResource()
of your portlet. Similary to the above, there is also RenderResponse.createResourceURL()
.All of the portlet tags belong to the portlet tag library - include it with <%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
, and call <portlet:defineObjects />
on the top of your JSP).
Calls to RenderResponse.create*Url()
methods return a PortletURL
class and doing a toString()
on them produces a string representation of the URL that can be included in markup produced by the portlet.
Both the portlet tags and PortletURL
instances also allow to specify portlet mode and window state to use to render the responses (either by tag attributes or by setters defined in the PortletURL
class).
For more, please see the spec.
Upvotes: 1