Daniel Platon

Ranch Hand
+ Follow
since Oct 10, 2005
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 Daniel Platon

Hello everyone,

(I'm actually using IceFaces, but this valid in a plain JSF context, too)
I'm trying to get around a very annoying problem: i have configured a resource bundle in my faces-config.xml file in order to retrieve messages according to the user's locale. The declaration is something like this:


In 80% of the cases I'm using this resource bundle in my jspx pages to display the interface in various languages. The problem is that when a key is missing from the properties file the server throws a nasty exception which I want to avoind by displaying the missing key name. For example, I'm using something like:

It the "login_username" key is missing from the bundle I want to display something like "??login_username??".

I know for a fact that this can be accomplished by implementing a custom resource bundle and overriding getString() so it catches MissingResourceException and returns whatever string I want instead BUT... I don't know how to tell JSF to use my resource bundle.

Thank you for your help.
11 years ago
JSF
I did a little research and came up with this issue. Turns out it's a Tomcat issue, for any versions prior to 6.0.18. I upgraded to 6.0.32 and everything works fine.

Thank you Tim for pointing me to the right direction!
11 years ago
JSF

I believe it is documented behaviour that @PostConstruct cannot be inherited, so you may just be out of luck.



Actually... I have performed the same test using a simple Spring application, with no JSF involved. The @PostConstruct annotation worked as expected, and the init() method of the superclass was called immediately after the constructor. This means that is really a JSF "bug" (or should I say... bad implementation).
11 years ago
JSF
Hello everyone,

Here's the problem - we have two classes:

class SuperBean, that has an init() method annotated with @PostConstruct

class NormalBean has no method whatsoever but extends SuperBean. NormalBean will just override some methods from the superclass

The jspx page displays the motd attribute using something like

Using the setting above the output in the browser is
This clearly means that the motd property is not set, i.e. the SuperBean.init() method does not run.

However, if I alter the NormalBean class like this:


The message in the browser displays correctly.

Why is this happening? I need the init() method to be only in the superclass, so the developer doesn't have to bother with the initialization stuff...
Actually, the original bug(?) is in IceFaces 1.8, but I tested it in a plain JSF1.2 application and I get the same behaviour, as you can see.

Thank you very much,
Dan
11 years ago
JSF
Request to a Spring controller which uses a JsonView to serialize the response to JSON...
Hello everyone,

Don't know if this is the right place for this question but here we go:
I need to interpret a JSON response (from a Spring controller) into a JSP page. Does anybody knows about some sort of taglib for that ? Basically... I need a JSON "parser" taglib.
I work with JSON because I use ExtJS widgets.

Thanks everyone.
Hello all,

First of all, why would you say I am using and old version ?
Thanks for your reply Rahul. The OFF level means "absolutely no output" and it works.
I seem to have discovered the problem. I removed the stdout appender from all categories except for the root category and it works now. The problem is I don't know the syntax to make the appenders "not additive" because I don't want the output from my classes to go to stdout

Thanks,
Dan
Ouuups ! Must be tired ! I was thinking about a "for" loop. The solution given by Ilja Preuss is actually ok, but why wouldn't one use "break" (hope i'm not too offtopic here)

Thanks,
Dan
15 years ago
Hello all,
There's definitely a great conversation here. Up till now I never felt the need to more than one return statement. Event when I put two return statements, I fell I could've gotten around with just one.

What attracted me was the tiny piece of code

now suppose X is a very large number and you have some more work to do in an iteration. Wouldn't be a less burden to do something like this ? -

because ok could become true in the first 10 iterations out of a hundred for example, so the code executes 90 times for nothing.

Thanks a lot,
Dan
15 years ago
Hello all,

I am trying to use log4j in my Struts application. So far I used the "defaults", i.e.

for initializing the logging system and then I used log.info(), log.debug() etc.
The problem is I am getting double posts in my logs. They have the same format, they have the same content. It just logs twice.
Why is this happening ? I searched the net and everything pointed to configuration issues when using custom loggers, but i'm not !
Below is my configuration of log4j.properties:



Any ideas ? Is this the way to use Log4J or do I have to write my own class ?

Thanks a lot !
Dan
[ May 03, 2007: Message edited by: Daniel Platon ]
Hello all,

I am trying to use log4j in my Struts application. So far I used the "defaults", i.e.

for initializing the logging system and then I used log.info(), log.debug() etc.
The problem is I am getting double posts in my logs. They have the same format, they have the same content. It just logs twice.
Why is this happening ? I searched the net and everything pointed to configuration issues when using custom loggers, but i'm not !
Below is my configuration of log4j.properties:



Any ideas ? Is this the way to use Log4J or do I have to write my own class ?

Thanks a lot !
Dan
[ May 03, 2007: Message edited by: Daniel Platon ]
15 years ago
Hello and thanks for the reply...

I'm sorry, I omitted the description of the mechanism, but yes, I have a base action class that intercepts unauthorized access(hey, it must be a common pattern ). Of course I could make my Ajax action extend some other class but I only solved half the problem. I still want the user to be redirected to the "login" page when it clicks a link that's supposed to fetch the response via Ajax.
I am using Ajax only for fetching data, no form submission.

Thanks again,
Dan
15 years ago
Hello all,

Now, here's a real problem (as opposed to my previous post ). I have implemented a mechanism in my application which automatically redirects the user to the login page if he/she is not logged in. This mechanism relies on the fact that I have to have the user's data in the session scope, so it basically ask the session for the User object and it this is null forwards the user to the login page.
There are some portions of my application where I used AJAX, and this is where the problem appeared. Wherever I click a link which is supposed the give me the response via AJAX (in a certain div on my page) and the session expired I get the login page in that div - no need to tell you how that's a big no-no.
Does anyone has any idea how I can solve this problem ?

Thanks a lot,
Dan
15 years ago
Problem solved.
The difference in behaviors between IE and FF comes from the fact that IE refresh the page fully (requesting all the images and css again so the SessionFilter removes the attribute. I fine-tuned the filter to only consider the requestURIs that end with *.do.

Have a good day,
Dan
15 years ago
Hello all,

Now here's an interesting one for you. In my webbapp I came to a point where I have to keep an object into the user's session for a short period of time. I developed a session filter that automatically removes the attribute unless the requestURI() is in an "accepted uris list". The scenario looks like this: the user clicks a link in a jsp, the link takes him into some action that retrieves an object from the underlying repository and stores it in the user session and then forwards the response to the jsp page. And here comes the weirdness. By using an Internet Explorer browser the attribute removes itself as soon as it's stored (I used a SessionListener class to notify me upon session events). When using Mozilla Firefox the attribute remains in the user's session but when I hit F5 on the page it gets removed. I found out that this is because of the SessionFilter but here comes a question for all you Struts gurus - why ? The first time the page loads everything works fine, as soon as I hit refresh - the attribute is gone. What happens behind the curtains ?

Thank you all,
Dan
15 years ago