Win a copy of Classic Computer Science Problems in Swift this week in the iOS forum!

Dave Mark

Greenhorn
+ Follow
since Feb 21, 2004
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 Dave Mark

Karthik Guru wrote:But I would like to know how Stripes compares with Struts2 though.


Here you go : Stripes vs. Struts2

And if I'm not mistaken Struts2 still doesn't have a simple way like this to have two different events for the same action. I've also lost the link to the workaround in the Struts2 documentation using a boolean for each event name, then testing for which boolean is set to true before invoking the correct method.
8 years ago

M Rama wrote:What do you use in your middle tier and data tier along with Stripes? Do you have a single toolset which you prefer on those arenas as well?



With Stripes, we use Spring and JPA. They also let you use annotations to wire things up automagically. Here's how you can use them with Stripes.
A response better-late-than-never I suppose.

I learned Struts back in 2006 after borrowing a Struts book. I remember trying for 2 days to get a simple example to work, only to find it was something very simple in the struts XML file I miss-typed. Once I got up to speed, I then developed an application which used a lot of Integer inputs and the validation/repopulation with '0' in the empty field values really bugged me. Lot's of other things (including tiles) also made me think, "there has to be an easier way to do this?".

Long story short, after looking at loads of introductory code examples, the Stripes framework's Quick Start Guide made me go, "No way! It can't be that simple". I downloaded it, copy-pasted the code and it worked. Changed a few things, added a few things, looked through the references on the website and thought, "blimey this is really easy!". In short, with Generified Advanced Indexed Properties, Stripes Layout Tags and being able to Unit Test ActionBeans (among lots of other things), I couldn't go back to Struts.

Unfortunately, I still had to work on projects with struts and help the junior programmers to use struts. They always struggle. But since I'm a senior développeur, I always leave the presentation layer to them while I develop the service layer and the JPA/DAO layer.    ;o)

All that's left is to convince the companies that hire us to use Stripes. If they hear struts, spring, jpa, hibernate, the like it. But they don't know Stripes so they think their internal staff wouldn't be able to take over once we're gone. The thing is, is that if you know struts, you practically already know Stripes and you'll be way more productive.

BTW, I put together two best practices we use on all of our projects to keep things strictly seperated and organised. This helps when many developers are working together on large projects (as well as unit testing) :

Stripes Spring JPA
Multiple Resource Bundles
8 years ago
Taking the query from this website as an example :is it possible to do something like this ?I've shortened it down everything to a minimum while still showing the result I'm looking for (and yes I know it doesn't work!).

What I have at the moment is something like the following...So is there anyway of getting closer to what I'm after?
Will a projection help me?
Or will I always have to iterate over the result to sort it?
Here's an updated version that searches for the level names in the log4j.properties file...and here's the output...
Got it

Thanks for the nudge in the right direction Paul

Thanks to Chapter 4 of Apress Pro Apache Log4j and the "Layout" section of this Czech web page here's what I came up with...

I18nedPatternLayout.java (line 13.)log4j.properties (line 05.)and I get...If they ask, I'll see if I can push the values into the log4j.properties file so I can do something like this...

Paul Clapham wrote:Log4J is open source. You can change it if you like.



Thanks for the reply Paul, but unfortunately the project has certain "recommendations" which they've imposed on us and they could change their mind anytime (which they've already done for something else)

I think I'll have to read up on extending ConsoleApender and DailyRollingFileApender to see if I can just do something like String.replace("ERROR", ERREUR).

Wish me luck. I'll post back what I come up with.

Cheers,

Dave
Thanks for the quick reply Omar but it's the level I'm trying to internationalize, we already use i18ned messages. I currently have this...

17:42:17,218 DEBUG AccueilAction:? - userId: user0000
17:42:17,218 ERROR AccueilAction:? - Test erreur

after going through loads of examples I came across this one so I tried it out (note line 08.)...It works! ...but now I'm getting two messages for only one log.error...

17:42:17,218 DEBUG AccueilAction:? - userId: user0000
17:42:17,218 ERROR AccueilAction:? - Test erreur
17:42:17,218 ERREUR AccueilAction:? - Test erreur
Does anyone know of a way to internationalize the levels : DEBUG, INFO, WARN, ERROR, FATAL

So that ERROR --> ERREUR

The messages themselves will be i18ned via resource bundles but I can't find anything in the log4j documentation to internationalize the level names. Anybody any ideas?
We have another situation with the group specifying possibly a type of "region", and if it doesn't that's normal too so no exception is to be thrown...

9 years ago
Thanks for the nudge in the right direction Rob. Sorry Oscar, I don't like UserState.L (what does that stand for!?) Some last minute reading and a few ideas later, I came up with the following as Rob suggested...I like my getEnum method so much now I made it public I'm also glad it's now scalable for the future while relaxing the rules for instantiating an instance. I can use either the value or the name (case insensitive) keeping UserState.ACTIVE in the Java code and "A", "I" etc. in the database as per the specification which I'm not allowed to change (the best of both worlds).It's a pity you can't override valueOf but heh, I'll document it. It'll be a lot better using this with Hibernate/JPA rather than going down this road!
9 years ago
Hi all,

I have a question about Java 5 enums. I'm trying to have UserState.ACTIVE in my code but have "A" saved to the database. Then when I get "A" from the database I get the enum representing UserState.ACTIVE. We're limited by the User POJO which can't change from using a String.

Here's my code so far...



I use the private method getEnum("A") instead of UserState.valueOf("A") as I get an error saying the value "A" doesn't exist (which I know it doesn't). The thing is, I'll have to modify the private getEnum method everytime a new state is added to the enum.

Is there a better way to code this enum so I can use UserState.valueOf("A") ?
9 years ago
I found the right order. In short I followed 'the branches' before continuing round 'the circle' so I did...

T1 --> T2 --> T3 --> T3B --> T3C
then
T3 --> T4 --> T5 --> T6 --> T7 --> T7B --> T7C
then
T7 --> T8 --> T1

My case was actually more complicated than I've described as I actually have a branch which is connected to two parts of 'the circle'. This branch itself having more branches.

So I finally ended up with something like this...

T1 --> T2 --> T3 --> T3B --> T3C
then
T3 --> T4 --> T5 --> 3B
then
T5 --> T6 --> T7 --> T7B --> T7C
then
T7 --> T8 --> T1

...which put all together became...

Hi all,

I'm having trouble ordering the joins in JPQL (with Hibernate 3). I have a database with about 20 tables and they're arranged in a sort of circle with two parts branching out, eg.

"-->" = "is joined to"

T1 --> T2 --> T3 --> T4 --> T5 --> T6 --> T7 --> T8 --> T1
and
T3 --> T3B --> T3C
and
T7 --> T7B --> T7C

I have to join all of these tables using "left join fetch". Joining T1, T2, ... T8, T1 is no problem...
but then I get an error when attempting to join one of the 'branches' (line 06.)
What is the correct ordering for joins?

Explanation :
The object/table t1 is actually the user and based on the user and based on their group/profile etc. we build menus and other stuff.
Why :
We're not allowed to use multiple requests to the database (we had 52 requests). Joining 'the circle' (T1, T2 ... T8, T1) with 'left join fetch' brings us down to 20 requests, but this is still too much. The application will be used by a huge amount of people all starting at 9 o'clock, so we don't want the log-in/create-menu phase to cripple the systems response time.

Any help much appreciated.