hasan's blog (বল্গ)

work for fun!!!

Archive for the ‘java ee’ Category

Nice Stripes web framework

with 3 comments

hi,
at least i could manage some time to write about Stripes (http://stripes.mc4j.org/)

stripes is a web framework, it has very few dependencies, configuration over convention is highly adopted on Stripes.

you don’t need to bother about any separate XML file or properties file, it is as simple as web.xml servlet configuration. just put your all configuration over

more over it has default convention centric url discovery… for example “HelloAction”.. this action can be accessed over “http:///Hello.htm” or whatever u map on url mapping.

very flexible system. it has very simple work flow management, (who already familiar with JSF navigation or Spring web flow will be interested on its work flow)

by default it has multi action on each class, and you can override the url or any settings over @annotation. which is the most powerful feature over stripes.

web form validation is one of the nice and simple approaches over stripes. i am really loving it..
you can apply validation rule over @annotation. here is few example.. hope it will give you clean understanding.

@ValidateNestedProperties({
@ValidateNestedProperties({
@Validate( field = “accountName”, required = true, on = {“register”}),
@Validate( field = “password”, required = true, minlength = 6, on = {“register”})})
private User user;

@Validate( expression = “user.password == this”, on = “register”, required = true)
private String confirmPassword;

it has support over spring container, so spring developer won’t get you out…

best wishes…

http://hasan.we4tech.com

Written by nhm tanveer hossain khan

February 11, 2007 at 11:49 pm

Wow, new configuration option on Spring 2.0

leave a comment »

hi today i found an interesting stuff..

Rod talked about new configuration option in spring (actually you can add as an addon) Define bean using Java code Wow!!!.. i was looking for this stuff for a long while… sometimes it is really meaningful to me…

here is code example for rod blog:

@Configuration
public class MyConfig {
@Bean
public Person rod() {
return new Person(“Rod Johnson”);
}@Bean(scope = Scope.PROTOTYPE)
public Book book() {
Book book = new Book(“Expert One-on-One J2EE Design and Development”);
book.setAuthor(rod())// rod() method is actually a bean reference !
return book;
}
}

Written by nhm tanveer hossain khan

December 8, 2006 at 1:52 am

iBatis PaginatedList and pagination

with 3 comments

iBatis has very good pagination support. every query can be limited by max number of rows and scrollable.
for example i have executed “queryForPaginatedList( “queryName”, domainObject, MAX_ROWS ) “;
iBatis PaginatedList class is extension of “java.util.List” class. so you can generally use it as collection object.
following methods are added to PaginatedList class:

    int getPageSize();

page size is current size of list (list.size() == MAX_ROWS)

    boolean isFirstPage();

if page offset is 0 no “nextPage” is invoked (default state)

    boolean isMiddlePage();

if between last and first offset (though did not use it, just assumption)

   boolean isLastPage();

if page offset == total available page

boolean isNextPageAvailable();

if current offset is not the last offset

    boolean isPreviousPageAvailable();

if current offset is not set to ’0′ i mean already (nextPage(…)) invoked.

    boolean nextPage();

hit database(or cache) to load next MAX_ROWS number of items

    boolean previousPage();

hit database(or cache) to load rows from certain range from current state to one step backward.

    void gotoPage(int i);

move forcefully to certain page by specified offset

int getPageIndex();

return current page index(offset) number

How to paginate through your records?:

1. let’s think some one accessed your controller, you performed some retrieval task, and stored this “PaginatedList” object into session context.
2. when user request for  “next” page. you just load your object from session and invoke “pgList.nextPage()”
3. when user request for “back/previous” page you just load your object from session and invoke “pgList.previousPage()”
4. and set again in session context.
5. access from view .. and render your desire UI…
regards and Eid Mubarak!!!

Written by nhm tanveer hossain khan

October 25, 2006 at 7:26 pm

Posted in Java, iBatis, java ee