留言板
Setting initial portlet mode to Edit
I am working with a version of the PrimeFaces demo found at https://www.liferay.com/community/liferay-projects/liferay-faces/demos and my goal is to use the Preferences dropdown (Edit portlet mode) to allow the user to configure a query to an Oracle database and display the results in a table (View portlet mode).
portlet.xml
I'm using a custom class that extends GenericFacesPortlet and I want the Edit mode to initially display and then once that is set the View mode should only be displayed. I'm attempting to set the ViewId to the Edit screen temporarily and then switch it back to portletViewMode.xhtml later (I havent figured out how/when to switch yet - just trying to get the Edit to display intially). However, this code still uses the View screen when the portlet is added even though I believe I am "overwriting" it with the Edit screen.
my java class
I am relatively new to custom portlet development using JSF. Is what I am attempting to do even possible and has anyone had success getting something similar to work? Could someone with more portlet experience help with this issue?
Thanks for your help,
Sean
portlet.xml
<portlet-name>status</portlet-name>
<display-name>Status</display-name>
<portlet-class>com.my.dashboard.portlet.SystemStatusPortlet</portlet-class>
<init-param>
<name>javax.portlet.faces.defaultViewId.view</name>
<value>/views/status/portletViewMode.xhtml</value>
</init-param>
<init-param>
<name>javax.portlet.faces.defaultViewId.edit</name>
<value>/views/status/portletEditMode.xhtml</value>
</init-param>
I'm using a custom class that extends GenericFacesPortlet and I want the Edit mode to initially display and then once that is set the View mode should only be displayed. I'm attempting to set the ViewId to the Edit screen temporarily and then switch it back to portletViewMode.xhtml later (I havent figured out how/when to switch yet - just trying to get the Edit to display intially). However, this code still uses the View screen when the portlet is added even though I believe I am "overwriting" it with the Edit screen.
my java class
public class SystemStatusPortlet extends GenericFacesPortlet{
public void doView(RenderRequest renderRequest, RenderResponse renderResponse)
throws PortletException, IOException {
renderRequest.setAttribute("javax.portlet.faces.defaultViewId.view", "/views/status/portletEditMode.xhtml");
super.doView(renderRequest, renderResponse);
}
}
I am relatively new to custom portlet development using JSF. Is what I am attempting to do even possible and has anyone had success getting something similar to work? Could someone with more portlet experience help with this issue?
Thanks for your help,
Sean
Kyle Joseph Stiemann,修改在10 年前。
RE: Setting initial portlet mode to Edit
Liferay Master 帖子: 760 加入日期: 13-1-14 最近的帖子
Hi Sean,
Since you probably want the initial portlet view to contain a freindly URL, it is probably best not to mess with EDIT mode initially. Instead, you can just have the portlet display the preferences view without switching to edit mode. There are two ways that this can be done:
Hope that helps,
- Kyle
Since you probably want the initial portlet view to contain a freindly URL, it is probably best not to mess with EDIT mode initially. Instead, you can just have the portlet display the preferences view without switching to edit mode. There are two ways that this can be done:
- You can add this line to PortletViewMode.xhtml:
Then in the backing bean, you just need to add code which decides what the default view is based on whether preferences have been chosen or not.<ui:include src="#{backingBean.defaultView}" />
- Otherwise, you can do this in PortletViewMode.xhtml:
In this case all that is needed in the backing bean is a boolean which knows whether preferences have been chosen or not.<c:choose> <c:when test="#{backingBean.preferencesSaved}"> <ui:include src="normal.xhtml" /> </c:when> <c:otherwise> <ui:include src="preferences.xhtml" /> </c:otherwise> </c:choose>
Hope that helps,
- Kyle