-
15. Re: Accessing Request parameters from jsf portlet
theute Jul 29, 2008 3:33 AM (in response to wesleyhales)Then this is not allowed. It breaks the principle of separation between portlets.
Another portlet on the same page shouldn't be affected by the url parameters targeted to another portlet.
The long term solution is to use public render parameters as we've done for regular webapps in 2.7.
JSR-301 still has to define its relation with Portlet 2.0 spec.
Anyway, Wesley is the Portlet bridge boss, it's up to him to decide if he wants to include the hack. -
16. Re: Accessing Request parameters from jsf portlet
eskape Jul 29, 2008 3:48 AM (in response to wesleyhales)Really strange. Our task, I suppose, is pretty common to any web application (either portal or servlet based) - like sending user to password restoration page or users exchanging direct links to specific photo gallery or whatever.
For instance, if we have this forum running within the portal page, how do I send anyone the link to this conversation?
It looks like http://www.jboss.com/index.html?module=bb&op=viewtopic&t=139184, so how could ForumPortlet access these "module", "op" and "t" parameters in its RenderRequest?
I've seen the "portlet targeted urls" term mentioned in the Portlet Spec, but did not find anywhere how to use it with JBoss Portal (tried to find it in Portlet Spec, Jboss Portal documentation, JBoss Wiki, Google - no success).
If there are any possibilites to use more portlet-specific URLs like http://localhost/portal/portal/default/restore/RestorePortlet?user=10000&code=fh4ufh92yf97ty9f, this will be absolutely suitable for us. -
18. Re: Accessing Request parameters from jsf portlet
eskape Jul 29, 2008 4:08 AM (in response to wesleyhales)nope :(
it does not.
http://localhost:8080/portal/portal/default/restore/EvaUserRestorePasswordPortlet?user=10000&code=fh4ufh92yf97ty9f
(PortletRequest) FacesContext .getCurrentInstance().getExternalContext().getRequest().getRequestParameterMap() is null
http://localhost:8080/portal/portal/default/restore/EvaUserRestorePasswordPortletInstance?user=10000&code=fh4ufh92yf97ty9f
(PortletRequest) FacesContext .getCurrentInstance().getExternalContext().getRequest().getRequestParameterMap() is still null
portlet.xml looks like this:... <portlet> <description>EvaUser Restore Password Portlet</description> <portlet-name>EvaUserRestorePasswordPortlet </portlet-name> <display-name>Eva User Restore password Portlet</display-name> <portlet-class>ru.eva.core.web.EvaFacesPortlet </portlet-class> <init-param> <name>javax.portlet.faces.defaultViewId.view </name> <value>/jsf/restore-password.xhtml</value> </init-param> <init-param> <name>default-view</name> <value>/jsf/restore-password.xhtml</value> </init-param> <supports> <mime-type>text/html</mime-type> <portlet-mode>VIEW</portlet-mode> </supports> <portlet-info> <title>Eva User Restore Password Portlet</title> <keywords>user,request password</keywords> </portlet-info> <expiration-cache>-0</expiration-cache> </portlet> ...
portlet-instances.xml:<deployment> <instance> <display-name xml:lang="en">Eva User Restore password Portlet</display-name> <instance-id>EvaUserRestorePasswordPortletInstance</instance-id> <portlet-ref>EvaUserRestorePasswordPortlet</portlet-ref> </instance> </deployment>
btw, I cannot use javax.portlet.faces.preserveActionParams init parameter because of this:
http://www.jboss.com/index.html?module=bb&op=viewtopic&t=139095
but I am not sure this is the case, because what we have here is a RenderRequest, not an ActionRequest -
19. Re: Accessing Request parameters from jsf portlet
eskape Jul 29, 2008 4:25 AM (in response to wesleyhales)Ok, I've just checked this to be sure:)
public class EvaFacesPortlet extends GenericFacesPortlet { @Override public Boolean getPreserveActionParameters() { return true; } }
So my faces portlet assumes that preserveActionParameters is always true.
The result is absolutely the same:
FacesContext .getCurrentInstance().getExternalContext().getRequest().getRequestParameterMap() is null -
20. Re: Accessing Request parameters from jsf portlet
theute Jul 29, 2008 5:33 AM (in response to wesleyhales)I would need to have a deep look at it, but i don't have the time at the moment. An action URL should work though.
-
21. Re: Accessing Request parameters from jsf portlet
eskape Jul 29, 2008 11:03 PM (in response to wesleyhales)ok, I'll file a JIRA bug regarding this, so you'll be able to get back to it when you'll have time
-
22. Re: Accessing Request parameters from jsf portlet
wesleyhales Aug 3, 2008 10:25 PM (in response to wesleyhales)portlet.xml looks like this:
... <portlet> <description>EvaUser Restore Password Portlet</description> <portlet-name>EvaUserRestorePasswordPortlet </portlet-name> <display-name>Eva User Restore password Portlet</display-name> <portlet-class>ru.eva.core.web.EvaFacesPortlet </portlet-class> <init-param> <name>javax.portlet.faces.defaultViewId.view </name> <value>/jsf/restore-password.xhtml</value> </init-param> <init-param> <name>default-view</name> <value>/jsf/restore-password.xhtml</value> </init-param> <supports> <mime-type>text/html</mime-type> <portlet-mode>VIEW</portlet-mode> </supports> <portlet-info> <title>Eva User Restore Password Portlet</title> <keywords>user,request password</keywords> </portlet-info> <expiration-cache>-0</expiration-cache> </portlet> ...
I think I see whyhttp://localhost:8080/portal/portal/default/restore/EvaUserRestorePasswordPortlet?user=10000&code=fh4ufh92yf97ty9f
is not working.
Try adding to your portlet.xml:<init-param> <param-name>javax.portlet.faces.preserveActionParams</param-name> <param-value>true</param-value> <init-param>
-
23. Re: Accessing Request parameters from jsf portlet
eskape Aug 5, 2008 3:25 AM (in response to wesleyhales)"wesleyhales" wrote:
Try adding to your portlet.xml:<init-param> <param-name>javax.portlet.faces.preserveActionParams</param-name> <param-value>true</param-value> <init-param>
Impossible :(
When I am adding this, GenericFacesPortlet throws an NPE on init :(
BTW, I've extended the portlet and overridden this getter to return true, but without any success... -
24. Re: Accessing Request parameters from jsf portlet
wesleyhales Aug 5, 2008 9:37 AM (in response to wesleyhales)Yep my bad, that xml snippet has a typo, it should be:
<init-param> <name>javax.portlet.faces.preserveActionParams</name> <value>true</value> </init-param>
-
25. Re: Accessing Request parameters from jsf portlet
wesleyhales Aug 5, 2008 9:38 AM (in response to wesleyhales)I am trying a few things to see how we can make this work. I will post when I have something.
-
26. Re: Accessing Request parameters from jsf portlet
wesleyhales Aug 5, 2008 3:22 PM (in response to wesleyhales)Thomas is right, you should generate an actionURL for this. As you mentioned this is dependent on the portal implementation and I'm not 100% sure about the restful capabilities of it.
-
27. Re: Accessing Request parameters from jsf portlet
eskape Aug 6, 2008 12:27 AM (in response to wesleyhales)"wesleyhales" wrote:
Thomas is right, you should generate an actionURL for this.
Could you please provide an example? Use-case is the same - current forum working in ForumPortlet, and I am going to send a topic link to my friend :) -
28. Re: Accessing Request parameters from jsf portlet
alexsmirnov Aug 12, 2008 5:11 PM (in response to wesleyhales)Portlet API have a special method in the RenderResponse interface : createRenderURL. From JSR-168 PLT 7.1 :
A render URL is an optimization for a special type of action URLs. The portal/portlet-
container must not invoke the processAction method of the targeted portlet.xxvi The
portal/portlet-container must ensure that all the parameters set when constructing the
render URL become render parameters of the subsequent render requests for the
portlet
Render URLs should not be used for tasks that are not idempotent from the portlet
perspective. Error conditions, cache expirations and changes of external data may affect
the content generated by a portlet as result of a request triggered by a render URL.
Render URLs should not be used within forms as the portal/portlet-container may ignore
25 form parameters.
Portlets can add application specific parameters to the PortletURL objects using the
setParameter and setParameters methods. A call to any of the setParameter
methods must replace any parameter with the same name previously set.xxviii All the
parameters a portlet adds to a PortletURL object must be made available to the portlet as
request parameters.xxix Portlet developers should note that the parameters of the current
30
render request are not carried over when creating a PortletURL.
Unfoutunately, it is a inconsistent implementation in the Jboss portletBridge JSF ExternalContecxt requestParametersMap, it contains an action parameters only, so use a request object "getParameter" method directly.