how to check ITEMS_FOR_LISTING in jsp

5 views
Skip to first unread message

Kishu

unread,
Nov 3, 2009, 2:35:31 AM11/3/09
to web4j-users
hi all,
am a newbie for this web4j framework.

Generally we do some database actions and add that result to
"ITEMS_FOR_LISTING" in Action class and that value is added to request
scope using addToRequest () method.

Now my doubt is how can we check the value of ITEMS_FOR_LISTING in jsp
page.

Also can we use any other variable in Action class which will be added
to addToRequest() method, if so please specify how to add that in
addToRequest() method and also how to check for the validity of that
variable in jsp page.


Awaiting your response.


Thanks in advance.

John O'Hanley

unread,
Nov 3, 2009, 5:30:19 PM11/3/09
to web4j-users
ActionImpl.addToRequest(String, Object) lets your action add any
object to 'request scope'.

When you say 'check the value of' what do you mean exactly?
1) check to see if it's present?
2) check the state of the object, for example an integer in range
1..10, and so on?
3) something else?

In the case of #1, you can simply use JSTL to check-for-empty/null

In the case of #2, the validation is performed by the Model Object,
not in the JSP. For example, this Model Object has validation of its
data in its validateState() method :
http://www.web4j.com/fish/javadoc/src-html/hirondelle/fish/main/member/Member.html#line.16

This validation is performed every time you construct the Model Object
- either from user input, or from a database SELECT operation.

The Model Object is added by an Action :
http://www.web4j.com/fish/javadoc/src-html/hirondelle/fish/main/member/MemberAction.html#line.49

using the method :
ActionImpl.addToRequest(String, Object)

The String/name "ITEMS_FOR_LISTING" is provided by web4j as a mere
convenience, but you can of course use and String/name you want.

If this is not helpful, please provide more information.

Regards,
John O'Hanley
Reply all
Reply to author
Forward
0 new messages