Everytime something gets wrong .. i got to see this.
How can i make a simple Errorpage with stacktrace in jsf ?
If you use Facelets (which is almost mandatory if you want to develop JSF webapps), an error page is automatically created. You can see an example here.
More generally, you can customize your web.xml in order to redirect the user when an error occurs.
Related
In my JSF 2.2 bases application I created a wizard which is based on #ConversationScope. To deal with errors I added CDI Conversation Filter to my web.xml.
My first question is about the right url-pattern for the filter-mapping. My Wizard runs behind the url /report/*. If I use this as pattern, all other pages throw the following exception:
javax.servlet.ServletException: A request must be associated with the context in order to load the known conversations
So, i had to use "/*" as pattern, which worked fine so far.
But now, I want to integrate container-managed security. When requesting the restricted resource, the mentioned error is thrown, when redirecting to login-page.
Does anybody know, how to solve that?
Thanks in advance.
We have a legacy JSF application running on jetty. It has pages like /foo/bar/mypage.xhtml with outputLink tags like: <h:outputLink value="?param1=value1">Click</h:outputLink>. These links are being generated without any context, and so when clicked, the browser correctly links to the current page with the specified parameters.
We recently installed Xebia's XForwardedFilter to fix issues with running the app behind a proxy. With it enabled, though, the link is getting generated by jsf with the context (which from my understanding is the correct behavior). Unfortunately, the context doesn't include anything after the last /, so the current page is not included in the link. For the example above, the link becomes /foo/bar/?param1=value1 instead of the desired /foo/bar/mypage.jsf?param1=value1
The workaround is to include the current page for the link value: <h:outputLink value="mypage.jsf?param1=value1">Click</h:outputLink>. The problem is that there are a lot of these links in the application and some of them are in includes which will require passing an additional parameter to indicate the page that should be referenced.
Is there a way to get the outputLink to generate the full context? Alternatively, if we could disable the context generation altogether so that the prior behavior occurs, that would work as well.
I am using MyFaces 1.1.14. I have two JSPX pages with JSF components and my managed bean is in request scope. At first page, bean constructor is getting fired and when I submit a form it is fired again. But after my app navigates to the new page, it is not getting fired. The constructor is supposed to be called, right?
The thing is that page is accessing some properties of the bean — those setters get called — no problem with that, but why is the constructor not called? When the page get loaded I need to get data from previous process (i.e from different framework). What is the problem with my understandings?
The navigation does by default not fire a new HTTP request. Instead, a different view is been used as content of the current HTTP response. Only when you navigate with a redirect by appending the <redirect/> entry to the <navigation-case>, then a new HTTP request would be created.
You should totally understand it if you're familiar with RequestDispatcher#forward() concept of the basic Servlet API which JSF is sitting on top of.
See also:
What is the difference between redirect and navigation/forward and when to use what? - Note that the code examples are targeted at JSF 2.x, but the principles apply as good on JSF 1.x.
We are developing web application using JSF. We are using rich faces on Jboss server. We have a4j command buttons , command links and a4j js functions to invoke server actions.
We have set limit render to true, render only required components. And I also set execute to "#this" . We are observing a strange behavior , All the actions associated with the form are also executed along with the button clicked, even though we have not specified the execute value to "#this". This is bringing down the performance drastically.
Is this the way JSF process POST requests or is there something else we are missing?
What you're currently describing in the question is definitely not the default behaviour of JSF nor RichFaces.
Your concrete problem is caused elsewhere. As per the comments, you seem to have created a PhaseListener for logging purposes which is re-executing the entire view for some reason. You'd need to turn off this PhaseListener or to fix its implementation.
I'm new to JSF and am trying to make a content controller. Basically whenever someone makes a request to www.myapp.com/external/** I'd like to forward to a controller that pulls external content into a page template and spits it out to the user.
For example /external/test/test.html might pull in content from a location XXYYZZ/test/test.html.
I was able to achive this pretty easily in Spring 3, but I'm a little confused on where to start with JSF.
I feel like I'd need to create a custom servlet to handle /external/**? But what would the class of this servlet be? What would it consist of?
Any help is appreciated!
I would suggest you not do this with the JSF servlet. Instead, do this with JAX-RS, or a custom servlet, or continue to do it with Spring. Map the custom servlet to a different URL pattern than your JSF pages. That way you can use JSF for the pieces where it is appropriate, and serve your static content as appropriate.
While I've never done so myself, Google yields plenty of examples where people have integrated Sping and JSF.