simple singularities

use resource bundle outside of Action in struts 2

Filed under: java,programming — fri13th January 17, 2009 @ 3:17 pm

i have to generate some logs in struts 2 framework. i know the action classes include resource bundle feature by just using getText() method. but i can’t find how i use resource bundle outside of Action classes. just google it and get no reasult.

i didn’t give up and download xwork2.0.7. (yes, xwork!) struts2.0.x source doesn’t contain old xwork code. and finally found some classes about that. DefaultTextProvider and LocalizedTextUtil. DefaultTextProvider is just a wrapper of LocalizedTextUtil.

1
2
TextProvider textProvider = DefaultTextProvider.INSTANCE;
log.info(textProvider.getText("some.property"));

i have to use Locale.US for logging. so…

1
LocalizedTextUtil.findDefaultText("some.property", Locale.US)

struts 2 has many good features but lacks of manual.. anyway, we can do what we want. if you don’t care about reading sources.. good luck to you

kyoto kotoin

Filed under: flickr — fri13th January 10, 2009 @ 10:22 am


kyoto kotoin, originally uploaded by lazy fri13th.

beatiful moment in kyoto
i always visit kyoto 2times an year, spring and autumn..
splendid experience!

empty post problem in struts2

Filed under: flickr — fri13th January 6, 2009 @ 9:22 pm

struts2 has annotation validation features, which makes validation javascript automatically. i didn’t know this feature also does server side validation. so if you turn off client side script for some custom validation, the server side validation prevents from submitting invalid input data.

that’s why i spend couple of time, today. i checked by using firebug and see there is no post data. it was very wierd experiences ever in this year..

so i fixed it by just delete annotation validate code.. and add more custom validation code. so as to say, if we know the cause, the solution isn’t difficult to find at all.