Struts

Name:
Location: Bangalore, India

Monday, March 10, 2008

How to iterate a single object which has 10 properties using struts UI tags.

In our example objIssuingBankOABank is a reference variable of IssuingBankOABean object which has 10 properties.

private IssuingBankOABean objIssuingBankOABank;

We have this property as part of RequestForm.

So we need to iterate this single object without putting it into a list and display all the values that’s part of this object.

<logic:notEmpty name="RequestForm" property="objIssuingBankOABank">
<bean:define id="IssuingBankOABean" name="RequestForm" property="objIssuingBankOABank"/>


≪bean:write name="IssuingBankOABean" property="overseasApprovalCount" />
≪bean:write name="IssuingBankOABean" property="pendingApprovalCount" />

≪/logic:notEmpty>

Monday, March 03, 2008

How to check not null and not empty string using tags

logic:present
name: Checks for the existence of a JSP bean, in any scope, with the specified name. If property is also specified, checks for a non-null property value for the specified property.
property: Checks for the existence of a non-null property value, returned by a property getter method on the JSP bean (in any scope) that is specified by the name attribute.

logic:notEmpty
Evaluate the nested body content of this tag if the requested variable is neither null, nor an empty string, nor an empty java.util.Collection (tested by the .isEmpty() method on the java.util.Collection interface).

name: The variable to be compared is the JSP bean specified by this attribute, if property is not specified, or the value of the specified property of this bean, if property is specified.
property: The variable to be compared is the property (of the bean specified by the name attribute) specified by this attribute

Before checking for a property against equal to or not equal to a particular value it is a good practice to ensure it is present and not empty.

<logic:present name="ABCForm" property="abcStatus">
<logic:notEmpty name="ABCForm" property="abcStatus">
<logic:notEqual name="ABCForm" property="abcStatus" value="2">