I have a JSF Portlet in a Portal page. I need to display a error page whenever an exception is thrown by any of the page bean methods. How can I do that?
I tried the below configuration in web.xml and it works for a servlet but not for a portlet.
<error-page>
<exception-type>java.lang.Exception</exception-type>
<location>/faces/exception.xhtml</location>
</error-page>
Right now whenever a page bean method throws exception, the application displays the first page.
I am using JSF 1.2 + Facelets and I don't have any additional 3rd party libraries.
I extended the IBM FacesPortlet which we were using and added exception handling in processAction and render methods.
Related
I'm using Java EE for an enterprise application on Glassfish.
I have some xhtml files in WEB-INF to prevent direct URL access, that I can access using a servlet. I need to call a method of a managed bean when the user press a button.
The xhtml code I'm using is:
<h:form><p:commandButton action="#{managedBean.testFunction()}" value="Test function" type="submit" ajax="false" styleClass="block" /></h:form>
The problem is that the input of h:form seems to redirect me to the actual path to my xhtml file, e.g.:
My servlet mapped at:
/ServlerDispatcher/DispatcherServlet
using:
request.getRequestDispatcher("/WEB-INF/HiddenFiles/fileA.xhtml").forward(request, response);
displays the xhtml file in the WEB-INF folder, that contains the form I mentioned above. Submitting the form, by pressing the button redirects me to this URL:
/ServlerDispatcher/WEB-INF/HiddenFiles/fileA.xhtml``
that cannot be displayed since it's in the WEB-INF folder to prevent direct URL access.
As I said what I really need is execute a managed bean method when the user press a button. How can I do that?
Thanks for your attention
I am working on a CQ 5.6.1 project. I am trying to find how to redirect the 404 error to a custom error page specific to my application. From reading various articles on error handling, I find that the /apps/sling/servlet/errorhandler/404.jsp is the one that handles 404 error. Since there are multiple projects deployed in the CQ, I need to show an error page I create under the project. That is, 404 error from the project1 must be redirected to a custom error page under project1. I was thinking that I should include the redirection code into the /apps/sling/servlet/errorhandler/404.jsp. Is this the right approach or is there a better way to automatically redirect to my projects error page?
This is the right approach. You don't have to create such a custom handler manually - ACS AEM Commons already provides a Error Page Handler supporting many sites.
I am creating a page using Liferay 6.2 where i need to display html contents sent as response from web service method. After seeing the customization and features available in web content display, i am planning to use them. As i am new to VM and FTL, i am not sure how to call web service method from web content display content. Please help me.
You can create a custom velocity tool as explained in this post.
Need your help guys. Any hint how can i dispaly a plain jsp in liferay context but without any liferay goodies, like theme, dockbar etc. Just a simple jsp page with some text.
I did that a while ago and what I did was to create a servlet in a portlet listening to some kind of URL. Example :
http://your-server:8080/my-portlet/my-servlet
Inside this Servlet you can then do a forward to the JSP in your portlet.
Any user accessing this URL will then be forwarded to a full JSP without any liferay stuff.
Is there an easy way to force the entire page to reload from Vaadin? I have a portlet which affects the header value displayed which is pulled from IBM WebSphere's dynamic cache in a separate JSP.
I am porting over an old JSF portlet to Vaadin which depending on page reloads between actions to reflect the new value in the header template. So now I need to force the entire page (not just the portlet) to reload to make it appear that the action took effect.
You can reload the hosting web page with JavaScript:
getMainWindow().executeJavaScript("window.location.reload();");
I think this should also do the trick in a portal.