掲示板
permissionsURL
Hi,
I need to have the ability to edit the Permsssion of objects by the users. Therefor I was happy to the Life liferay-security:permissionsURL tag. I only can genreate a textlink with that but I want to use the url inside a button, Is it possible to use a button or image instead of the Text?
I need to have the ability to edit the Permsssion of objects by the users. Therefor I was happy to the Life liferay-security:permissionsURL tag. I only can genreate a textlink with that but I want to use the url inside a button, Is it possible to use a button or image instead of the Text?
11年前 に Neil Griffin によって更新されました。
RE: permissionsURL (回答)
Liferay Legend 投稿: 2655 参加年月日: 05/07/27 最新の投稿
Currently the liferay-security:permissionsURL JSF component only supports generating an anchor hyperlink. In order to get the URL though, you could try something like this in a JSF managed-bean:
FacesContext facesContext = FacesContext.getCurrentInstance();
String family = "com.liferay.faces.portal.PermissionsURL";
String rendererType = "com.liferay.faces.portal.PermissionsURLRenderer";
PermissionsURLRenderer permissionsURLRenderer = (PermissionsURLRenderer) facesContext.getRenderKit().getRenderer(family, rendererType);
PermissionsURL permissionsURLComponent = new PermissionsURL();
permissionsURLComponent.setRedirect("http://..."); // put your redirect url here
permissionsURLComponent.setModelResource("com.liferay.portal.model.User"); // example model-resource FQCN
String permissionsURL = permissionsURLRenderer.getPermissionsURL(facesContext, permissionsURLComponent);
It works.
Glad to hear it.
With the code above it is possible to load the "Permission Editor Site" for the entity.
I noticed that there is a difference beetween the LiferayFaces RC1 and the RC2-Snapshot because of the URLRendering. To using this code inside an action (e.g. with commandButton) it is nessesary to have the RC2-SANPshot otherwise a ClassCastException is thrown. (More details)
I still have a little problem. After loading the site for editing the permission and than using the "back to page" link I got a ViewExpiredException if I try to do something.
If I safe the permissions before going back there is no problem.The go back links are diffrent.
Before Saving
http://localhost:8080/web/guest/ebook-management?p_p_id=86&p_p_lifecycle=0&p_p_state=normal&p_p_state_rcv=1&_86_modelResource=Book&_86_portletResource=ebookmanagement_WAR_ebookmanagementportlet&_86_struts_action=%2Fportlet_configuration%2Fedit_permissions&_86_resourcePrimKey=1302
after Saving
http://localhost:8080/web/guest/ebook-management?p_p_id=86&p_p_lifecycle=0&p_p_state=normal&p_p_state_rcv=1
I noticed that there is a difference beetween the LiferayFaces RC1 and the RC2-Snapshot because of the URLRendering. To using this code inside an action (e.g. with commandButton) it is nessesary to have the RC2-SANPshot otherwise a ClassCastException is thrown. (More details)
I still have a little problem. After loading the site for editing the permission and than using the "back to page" link I got a ViewExpiredException if I try to do something.
If I safe the permissions before going back there is no problem.The go back links are diffrent.
Before Saving
http://localhost:8080/web/guest/ebook-management?p_p_id=86&p_p_lifecycle=0&p_p_state=normal&p_p_state_rcv=1&_86_modelResource=Book&_86_portletResource=ebookmanagement_WAR_ebookmanagementportlet&_86_struts_action=%2Fportlet_configuration%2Fedit_permissions&_86_resourcePrimKey=1302
after Saving
http://localhost:8080/web/guest/ebook-management?p_p_id=86&p_p_lifecycle=0&p_p_state=normal&p_p_state_rcv=1
When you get a chance, please paste the stacktrace for the ViewExpiredException. Thx.
Here it is:
15:29:55,296 ERROR [ExceptionHandlerAjaxImpl:57] viewId:/html/booksManagement/mainView.xhtml - Ansicht /html/booksManagement/mainView.xhtml konnte nicht wiederhergestellt werden.
javax.faces.application.ViewExpiredException: viewId:/html/booksManagement/mainView.xhtml - Ansicht /html/booksManagement/mainView.xhtml konnte nicht wiederhergestellt werden.
at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:205)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at com.liferay.faces.bridge.lifecycle.LifecycleWrapper.execute(LifecycleWrapper.java:35)
at com.liferay.faces.bridge.BridgePhaseResourceImpl.execute(BridgePhaseResourceImpl.java:111)
at com.liferay.faces.bridge.BridgeImpl.doFacesRequest(BridgeImpl.java:106)
at javax.portlet.faces.GenericFacesPortlet.doBridgeDispatch(GenericFacesPortlet.java:700)
at javax.portlet.faces.GenericFacesPortlet.serveResource(GenericFacesPortlet.java:291)
at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:118)
at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:71)
at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:93)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:72)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:70)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:471)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:402)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)
at com.liferay.portlet.InvokerPortletImpl.invoke(InvokerPortletImpl.java:634)
at com.liferay.portlet.InvokerPortletImpl.invokeResource(InvokerPortletImpl.java:746)
at com.liferay.portlet.InvokerPortletImpl.serveResource(InvokerPortletImpl.java:503)
at com.liferay.portal.action.LayoutAction.processPortletRequest(LayoutAction.java:941)
at com.liferay.portal.action.LayoutAction.processLayout(LayoutAction.java:664)
at com.liferay.portal.action.LayoutAction.execute(LayoutAction.java:244)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
at com.liferay.portal.struts.PortalRequestProcessor.process(PortalRequestProcessor.java:174)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
at com.liferay.portal.servlet.MainServlet.callParentService(MainServlet.java:533)
at com.liferay.portal.servlet.MainServlet.service(MainServlet.java:510)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:72)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:113)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:113)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:113)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:121)
at com.liferay.portal.servlet.filters.secure.SecureFilter.processFilter(SecureFilter.java:201)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:203)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:105)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:121)
at com.liferay.portal.servlet.filters.autologin.AutoLoginFilter.processFilter(AutoLoginFilter.java:240)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:203)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:105)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:70)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:471)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:402)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)
at com.liferay.portal.servlet.FriendlyURLServlet.service(FriendlyURLServlet.java:135)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:72)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:113)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:113)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:121)
at com.liferay.portal.servlet.filters.gzip.GZipFilter.processFilter(GZipFilter.java:123)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:203)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:105)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:121)
at com.liferay.portal.servlet.filters.secure.SecureFilter.processFilter(SecureFilter.java:201)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:203)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:105)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:121)
at com.liferay.portal.servlet.filters.i18n.I18nFilter.processFilter(I18nFilter.java:241)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:203)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:105)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:121)
at com.liferay.portal.servlet.filters.etag.ETagFilter.processFilter(ETagFilter.java:55)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:203)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:105)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:121)
at com.liferay.portal.servlet.filters.autologin.AutoLoginFilter.processFilter(AutoLoginFilter.java:240)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:203)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:105)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:121)
at com.liferay.portal.servlet.filters.sso.ntlm.NtlmPostFilter.processFilter(NtlmPostFilter.java:83)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:203)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:105)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:121)
at com.liferay.portal.sharepoint.SharepointFilter.processFilter(SharepointFilter.java:80)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:203)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:105)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:121)
at com.liferay.portal.servlet.filters.virtualhost.VirtualHostFilter.processFilter(VirtualHostFilter.java:208)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:203)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:105)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:184)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:92)
at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:738)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:203)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:105)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:164)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:92)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:164)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:92)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:184)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:92)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:70)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:928)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:539)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:300)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
I realize that you are not using the liferay-security:permissionsURL component tag directly for your use-case, but can you try the following in your Facelet view and let me know what happens? I just tried it and it worked.
<liferay-security:permissionsurl modelresource="com.liferay.portal.model.User" modelresourcedescription="Current User" resourceprimkey="#{liferay.user.userId}">
<h:outputtext value="Permissions" />
</liferay-security:permissionsurl>
I've got the same problem.
What component suite are you using? ICEfaces/PrimeFaces/RichFaces?
The <liferay-security:permissionsURL ... /> example I pasted above works fine with a plain JSF2 portlet.
The <liferay-security:permissionsURL ... /> example I pasted above works fine with a plain JSF2 portlet.
I use it with a lot of primefaces components.
Hey Neil,
I'v just use the permissionURL-Tag to genrate the link but I use it in a p:dateTable and in there are other p:commandButtons in it. The link to get the permissionView is just the following.
A picture can say more than words.
I'v just use the permissionURL-Tag to genrate the link but I use it in a p:dateTable and in there are other p:commandButtons in it. The link to get the permissionView is just the following.
<liferay-security:permissionsurl modelresource="Book" modelresourcedescription="Book" resourceprimkey="#{book.bookId}">
<h:outputtext value="TEST"></h:outputtext>
</liferay-security:permissionsurl>
A picture can say more than words.
添付ファイル:
Hi Jan,
Thanks for the picture! It was very helpful. Can you paste the URL of the TEST link, and also the URL of the "Go Back" link that is causing the problem?
Thanks,
Neil
Thanks for the picture! It was very helpful. Can you paste the URL of the TEST link, and also the URL of the "Go Back" link that is causing the problem?
Thanks,
Neil
Here they are.
TESTLink:
http://localhost:8080/web/guest/ebook-management?p_p_id=86&p_p_lifecycle=0&p_p_state=maximized&p_p_mode=view&p_p_col_id=column-2&p_p_col_count=1&_86_struts_action=%2Fportlet_configuration%2Fedit_permissions&_86_portletResource=ebookmanagement_WAR_ebookmanagementportlet&_86_modelResource=Book&_86_modelResourceDescription=Book&_86_resourcePrimKey=1501
Go Back Link:
http://localhost:8080/web/guest/ebook-management?p_p_id=86&p_p_lifecycle=0&p_p_state=normal&p_p_state_rcv=1&_86_modelResource=Book&_86_portletResource=ebookmanagement_WAR_ebookmanagementportlet&_86_modelResourceDescription=Book&_86_struts_action=%2Fportlet_configuration%2Fedit_permissions&_86_resourcePrimKey=1501
TESTLink:
http://localhost:8080/web/guest/ebook-management?p_p_id=86&p_p_lifecycle=0&p_p_state=maximized&p_p_mode=view&p_p_col_id=column-2&p_p_col_count=1&_86_struts_action=%2Fportlet_configuration%2Fedit_permissions&_86_portletResource=ebookmanagement_WAR_ebookmanagementportlet&_86_modelResource=Book&_86_modelResourceDescription=Book&_86_resourcePrimKey=1501
Go Back Link:
http://localhost:8080/web/guest/ebook-management?p_p_id=86&p_p_lifecycle=0&p_p_state=normal&p_p_state_rcv=1&_86_modelResource=Book&_86_portletResource=ebookmanagement_WAR_ebookmanagementportlet&_86_modelResourceDescription=Book&_86_struts_action=%2Fportlet_configuration%2Fedit_permissions&_86_resourcePrimKey=1501
11年前 に Neil Griffin によって更新されました。
RE: permissionsURL (回答)
Liferay Legend 投稿: 2655 参加年月日: 05/07/27 最新の投稿
OK I reproduced the problem and I think I have an answer for you.
Try adding a "redirect" attribute to your liferay-security:permissionsURL tag, like this:
You will also need to add the following namespace at the top of your Facelet view:
Try adding a "redirect" attribute to your liferay-security:permissionsURL tag, like this:
[b]<portlet:renderurl var="currentPageRenderURL" />[/b]
<liferay-security:permissionsurl modelresource="Book" modelresourcedescription="Book" [b]redirect="#{currentPageRenderURL}" [ b] resourceprimkey="#{book.bookId}">
<h:outputtext value="TEST"></h:outputtext>
</liferay-security:permissionsurl>
You will also need to add the following namespace at the top of your Facelet view:
[b]xmlns:portlet="http://java.sun.com/portlet_2_0"[/b]