掲示板

JSF tags not rendered on doView

thumbnail
12年前 に Olivier ROMAND によって更新されました。

JSF tags not rendered on doView

New Member 投稿: 24 参加年月日: 12/01/07 最新の投稿
Hi people,

I'm struggling on some very simple stuff, but can't get it working.

I have a portlet with a dedicated portlet class inheriting from GenericsFacesPortlet. I want the portlet to choose which view to display depending on some action.

- When the user triggers the search command, we would run the search and display the results.
- When the user triggers the advanced search command, we would display the advanced search view.

The portlet.xml file is as follow:


 <portlet>
        <portlet-name>AutonomySearch</portlet-name>
        <display-name>AutonomySearch</display-name>
        <portlet-class>fr.sg.steria.portlet.SearchActionPortlet</portlet-class>
        <init-param>
            <name>javax.portlet.faces.defaultViewId.view</name>
            <value>/xhtml/autonomysearch/portletAdvancedSearch.xhtml</value>
        </init-param>
        <supports>
            <mime-type>text/html</mime-type>
            <portlet-mode>view</portlet-mode>
        </supports>
        <portlet-info>
            <title>AutonomySearch</title>
            <short-title>AutonomySearch</short-title>
        </portlet-info>
        <security-role-ref>
            <role-name>administrator</role-name>
        </security-role-ref>
        <security-role-ref>
            <role-name>guest</role-name>
        </security-role-ref>
        <security-role-ref>
            <role-name>power-user</role-name>
        </security-role-ref>
        <security-role-ref>
            <role-name>user</role-name>
        </security-role-ref>
    </portlet>


I overriden the doView method that way:

	@Override
	protected void doView(RenderRequest renderRequest,
			RenderResponse renderResponse) throws PortletException, IOException {
                    PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher("/xhtml/autonomysearch/portletSearchResults.xhtml"); 
                     rd.include(renderRequest,renderResponse);
     	}


Finally, the .xhtml file is as follow:


<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:aui="http://portletfaces.org/alloyfaces/aui" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:bridge="http://portletfaces.org/bridge" xmlns:example-cc="http://java.sun.com/jsf/composite/example-cc" xmlns:ui="http://java.sun.com/jsf/facelets">
	
	<ui:remove>
	<!-- 
			Necessary to include jsf.js manually to get the library loaded.
		 -->
	</ui:remove>
	<h:outputscript library="javax.faces" name="jsf.js" />
	
	<p>Here, there's the list of results</p>

	<br>

	<div style="border:1px black solid;">
	
	</div>
</ui:composition>


1) What happens is that the include would just "copy" the view, whithout interpreting anything of it. See below:



2) If I use forward in the doView method, rather than include, I would end up in error with "Portlet isn't available ... "

Would you be so kind to bring a bit of expertise here ?

Thanks really much in advance.
thumbnail
12年前 に David H Nebinger によって更新されました。

RE: JSF tags not rendered on doView

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
Rather than including the xhtml directly, try including the /xhtml/autonomysearch/portletSearchResults.faces instead. Include is just pulling in the file and including (but not interpreting it), but you need to include the result of the faces servlet's rendering of the xhtml file...
thumbnail
12年前 に Olivier ROMAND によって更新されました。

RE: JSF tags not rendered on doView

New Member 投稿: 24 参加年月日: 12/01/07 最新の投稿
Thanks for the input David,

But the framework didn't get tricked.

1) Is the way of working conceptually correct ?
2) Any chance to have some workaround ? or reason of such poor behavior ?

Thanks !
thumbnail
12年前 に David H Nebinger によって更新されました。

RE: JSF tags not rendered on doView

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
Well normally I'd handle this stuff directly within the JSF page itself, rather than trying to patch together a solution using the import option within the doView() method...
thumbnail
12年前 に Olivier ROMAND によって更新されました。

RE: JSF tags not rendered on doView

New Member 投稿: 24 参加年月日: 12/01/07 最新の投稿
Thanks for the input David.

It took me a while to understand what you meant by handling it in JSF.
I went for a view with show/hide controls using a boolean attribute, but it didn't fit my needs.
Next step has been to handle navigation through redirection within a Backing Beans to pass parameters to a <f:viewParam>

Anyway, thanks again !
thumbnail
11年前 に Ranga Rao Bobbili によって更新されました。

RE: JSF tags not rendered on doView

Regular Member 投稿: 152 参加年月日: 07/07/20 最新の投稿
Hi All,

My solution to override view dynamically in the doView()

Step1:
Mention init-parameter for default view

<init-param>
<name>javax.portlet.faces.defaultViewId.view</name>
<value>/template/ctmgmt/appealsImpl/providerAppealsImpl.xhtml</value>
</init-param>

Step2:

Override doView() or render() method in custom GenericFacesPortlet and mention below code snippet instead of RequestDispacher.include() or RequestDispacher.forward().


public void render(RenderRequest renderRequest,
RenderResponse renderResponse) throws PortletException, IOException {
getDefaultViewIdMap().put("view","/template/ctmgmt/appealsImpl/programAppealsImpl.xhtml");
super.render();
}


Thanks,
Ranga Rao Bobbili
Adaequare INC
9年前 に Steven Birr によって更新されました。

RE: JSF tags not rendered on doView

New Member 投稿: 18 参加年月日: 14/01/22 最新の投稿
Thank's! For me this worked also:

In portlet.xml:

		<portlet-class>Path_To_Your_PortletClass</portlet-class>
		<init-param>
			<name>jsf-view1</name>
			<value>/WEB-INF/html/jsftest/jsfview.xhtml</value>
		</init-param>


In Portlet code:

  public void doView(RenderRequest request, RenderResponse response) throws IOException, PortletException
  {
    getDefaultViewIdMap().put("view",getInitParameter("jsf-view1"));
    super.doView(request, response);
  }