• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

How to check multibox value is null?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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....
 
Sheriff
Posts: 22656
126
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic