This week's giveaway is in the Testing forum.
We're giving away four copies of TDD for a Shopping Website LiveProject and have Steven Solomon on-line!
See this thread for details.
Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!

Adrian Bustos

Greenhorn
+ Follow
since Apr 25, 2011
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Adrian Bustos

Hi,

This topic is related to one I previously posted (Exception handling in Faces Filter).

As it says... I want to catch every exception inside a catch on a Filter I wrote, this exception will be store temporally in a session bean and treated in a differente way than usual.
My filter ended up looking like this...




This keeps what I assume is some error flag or something as true but does not raise the 500 error code to the container thus avoiding the page redirection. Exactly what I needed to do.
Using Tomcat 6x within Eclipse works ok.
But when I run the same Tomcat installation as standalone my application (wich was previously packaged as a WAR file and deployed in the webapps directory) redirects to the 500 error page.

It's really odd to me because, as I said, i'm using the same Tomcat installation.

Any ideas of what the cause could be?
Is there a difference between the way Eclipse starts the tomcat and the way it starts by executing the "run.bat"?
Is there another way to let the servlet know that an exception must not be raised as a 500 error code?
Would that other way keep that internal error flag used by the a4j:queue JSF component to raise the "onerror" event?


Thanks in advance






10 years ago

Tim Holloway wrote:
1. The traditional method of setting an exception interceptor in web.xml. This is done the same for JSF as it is for non-JSF webapps.

Unacceptable. Define de filter, wrap your forms in a custom tag and, also, define an interceptor in you web app? Since to much to remember to make it work.

Tim Holloway wrote:
2. Catching the exception in the outbound leg of the filter. This one's more questionable, since there may be content already sent out, but at least you can log the status code and squirrel it away in a session parameter or something like that.

Could you exlpain a little more? Maybe an example?

Tim Holloway wrote:
3. Subclassing the form tag itself. If you've already gone through the agony of creating custom JSF tags, you've already got the practice. Just produce the parameter as part of the rendering process.

Unacceptable.

Tim Holloway wrote:
4. Creating a special-action form element tag. This is basically just a way of coding the hidden parameter, except that it's more meaningful in business terms. Plus, it allows you to specify additional options, if desired. This is probably better than subclassing the form tag, since you don't have 2 different types of form tags - just forms tagged with special behavior.


Unacceptable

Remember that I made it posibble to add the hidden dinamically iterating the children of CustomHiddenSetter.



Problem is when the UIForm is rerendered.

If that approach is correct. I'm pretty sure I'm missing something in the methods processRestoreState or processSaveState or something like that...
I'm not that experienced with JSF custom component development.

Why to I insist with the hidden? Because is the simplest way to send, in this case, a flag that tells the filter if it should treat the exceptions differently in that particular request
10 years ago
JSF

Carl Manschold wrote:What is your purpose with this?



My purpose is to catch, using this filter, all the exceptions thrown in every request of every form that lies inside a custom JSF component. But not every form in the web site. That's why I can't just set a session value.



In this example, all exceptions thrown by every request of "a4jfrmForm1" or "a4jfrmForm2" will be treated differently than ussual while all exceptions thrown by "a4jfrmForm3" will not.

The catch is that I'm writing a reusable JSF component that handles this automatically. All the programmer has to do is, well to set the filter in his web.xml, and wrap all forms (only those necesary ;)) inside of <xxxx:customHiddenSetter>.
Asking him to also put an <input hidden type... seems a little bit lame and redundant.
10 years ago
JSF

Tim Holloway wrote:This seems to be a really complicated solution to what appears to be a simple problem.

Why is is necessary to go to the trouble of injecting a parameter on each and every JSF form submit? It's complicating the app, it's extra network traffic, it's a potential security hole, and last - but not least - if the server is just going to "talk to itself", why bother? Why not just keep the information on the server in a session object (or, if it's global, in an application-scope object)?



It would be easy for me to keep that value (wich, by the way it could only be true|false) in the web.xml.
That value is a flag. It says the filter "Do this or do that... in case of...", it does not risk the security of the application at any time and not in all request is necesary.


10 years ago
JSF
Hello.

I'm trying to make sure that a specific parameter be send on every request so I can read it from a filter.



This is easy to accomplish if I do something like this:


The problem is that every time I use an UIForm on the page I've to set the hidden tag.

So I thought in writing a custom JSF component that does it for me.

CustomHidden it's just another custom JSF component that spits the hidden HTML code;


the implementation would look like this...

...and works great! Every time a request is made from "a4jfrmMyForm" I see the value of "_parameterName".
The problem is when the forms are reRendered they do not encode CustomHidden added manually from CustomHiddenSetter. So in order to make this works again I have to refresh manually (F5).

I accept any suggestion. The goal, here, is to make sure that every request inside the children forms of CustomHiddenSetter (like "a4jfrmMyForm", "a4jfrmAnotherOne" or "a4jfrmYetAnotherOne"... BUT NOT "a4jfrmOutsiderForm" ) have to carry the parameter "_parameterName" along with its value.

Thanks in advance!
10 years ago
JSF
Ok, I think I solved it


11 years ago
JSF
Hi everyone, I've got a little problem regarding exception handling in a custom filter I wrote.

This was working OK until I start using a4j:queue control.

If no exception is raised during de request call, all events are raised (onbeforedomupdate, onrequestqueue, onrequestdequeue, oncomplete and onerror) but "onerror" and "oncomplete" won't raise when an exception is thrown. This is because I treat the exception and do not invoke the "doFilter" method inside the catch.

If I'd invoke the doFilter method those 2 events (oncomplete and onerror) are executed, but the Error 500 pages appears on the client side and that's something I want to avoid.

So... I came to the theory that the doFilter method should be invoked but before that these two objects servletRequest, servletResponse must be treated so the servlet won't fire an Error 500 page redirection.

Any ideas?
11 years ago
JSF
Hi Everyone, this is my first post.

I found myself in a pickle regarding session managing in JSF.

For the sake of argument let's say I've a bean that returns the server'current time

Then there's a page that invokes this method every seccond

This works great, but every time this method is invoked the session's lastAccessedTime property is updated.
I need to void this to happend, but only for this specific method invokation.

How can I make that possible?

web.xml

faces-config.xml

Thanks in advance!
11 years ago
JSF