Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to check multibox value is null?  RSS feed

 
Aswathy TS
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am getting the value of a multibox as a string array...but if none of the boxes are checked then the value becomes null and it is giving null pointer exception...How can i solve that?
My jsp code is
<logic:iterate id="data" name="resourcelist"
type="com.sp.dct.security.bo.ResourceBO" indexId="index">

<tr>
<td><html:multibox property="resourcechecked"
value="<%=data.getResourceName()%>"></html:multibox></td>

<td><bean:write name="data" property="resourceId" />

</td>
<td><bean:write name="data" property="resourceName" /></td>
<td><bean:write name="data" property="description" /></td>
<td><html:multibox property="viewStatusChecked"
value="<%=data.getResourceName()%>"></html:multibox></td>
<td><html:multibox property="editStatusChecked"
value="<%=data.getResourceName()%>"></html:multibox></td>



and corresponding action class code is


String[] resourceName=new String[30];
String[] viewChecked=new String[30];
String[] editChecked=new String[30];

resourceName= roleBean.getResourcechecked();
viewChecked=roleBean.getViewStatusChecked();
editChecked=roleBean.getEditStatusChecked();

I have tried with array length property ,.equals(null)....everything is giving null pointer exception...Please give some solution....
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Aswathy TS",

Please read your private messages regarding an important announcement.

Thank you,

Rob


Originally posted by Aswathy TS:
I have tried with array length property ,.equals(null)....everything is giving null pointer exception...Please give some solution....

How about actually checking if the variable is null first?

Anyway, moving to JSP.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!