my dog learned polymorphism*
The moose likes Struts and the fly likes Collecting Values from remove div Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Collecting Values from remove div" Watch "Collecting Values from remove div" New topic
Author

Collecting Values from remove div

Ram Mandavkar
Greenhorn

Joined: Mar 23, 2009
Posts: 16
I am New o struts 2,
I am using remove div method to populate search result into a table with struts tag checkbox, I can able to traverse through search result with four link ( FIRST, NEXT, PRIVIOUS, LAST )
In my action class I am getting null pointer exception (java.lang.NullPointerException)at
for (Iterator<String> iterator = isSelectedData.iterator(); iterator.hasNext();)
While collecting checked values from Remotediv.jsp

I did not understand why this exception is coming
And
How to access values from remove div where a nex jsp is getting render which is pare of Index.JSP.

index.jsp

<table>
<td>
<s:url id="url" action="Searchresult" method="next"/>
<s:a theme="ajax" targets="two" href="%{url}" ><b>First</b>
</s:a>
</td>
</table>
<div id="two" style="border: 1px solid yellow;width:823px;height:350px;">
</div>

Config file

<action name="Searchresult" class="remotemonitor.userpreset.SearchResultAction" >
<result name="success">/jsp/remotemonitor/userpreset/SearchResult.jsp</result>
</action>

SearchResultAction.java Actionclass

private ArrayList<String> isSelectedData;
private List<SearchResultDAO> searchResultDAO;

public String next() throws Exception{
for (Iterator<String> iterator = isSelectedData.iterator(); iterator.hasNext();) {
String key = iterator.next();
if(key.equals("false")){
break;
}
System.out.println("Selected : "+ key);
}
setSearchResultDAO((List<SearchResultDAO>) new ArrayList());
for( int j=11;j<=20;j++ ){
SearchResultDAO Data_List = new SearchResultDAO();
Data_List.setPresetid(""+j);
Data_List.setPresetnm( "ROW"+j );
Data_List.setChecked(false);
getSearchResultDAO().add( Data_List );
}
}

public ArrayList<String> IsSelectedData() {
return isSelectedData;
}
public void setIsSelectedData(ArrayList<String> isSelectedData) {
this.isSelectedData=isSelectedData;
}
}

Remotediv.jsp

<table width="50%" border="1">
<s:iterator value="searchResultDAO">
<tr class='fieldsetfont'>
<td width="9%" align="center" bgcolor="#6389A0" class="frontValid11">
<s:checkbox labelposition="right" name=" isSelectedData"
label="%{presetnm}" value="%{presetCheck}" fieldValue="%{presetid}"/>
</td>
<td width="19%" align="center" bgcolor="#6389A0" class="frontValid11">
<s:a theme="simple" href="UserPreset.action?presetid=%{presetid}">
<s:property value="presetid" />
</s:a>
</td>
<td width="68%" align="center" bgcolor="#6389A0" class="frontValid11"> <s:property value="presetnm" />
</td>
</tr>
</s:iterator>
</table>
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Please UseCodeTags when posting code or configuration. Unformatted code and configuration is very difficult to read. You can edit your post to include them by using the button.

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I don't see a form or JavaScript submission anywhere; how are you sending the checkboxes to the action?
Ram Mandavkar
Greenhorn

Joined: Mar 23, 2009
Posts: 16
David Newton wrote:I don't see a form or JavaScript submission anywhere; how are you sending the checkboxes to the action?


I was bit delayed.


Ram Mandavkar
Greenhorn

Joined: Mar 23, 2009
Posts: 16
As shown in index.jsp ( form tag is missing in above code but it is there in my code
<s:form id='theForm2' theme="ajax" > )

‘FIRST ‘ is the link with action="Searchresult" method="next" theme="ajax"
If I click on ‘FIRST’ link then ‘Searchresult’ action will get called and index.jsp page is submitted and result jsp page (Remotediv.jsp) will get render into index.jsp as <div id="two"/>

How to send the checkboxes from Remotediv.jsp(Which are not part of index.jsp) page to the action(Searchresult)?
or
So how to access remote page(Remotediv.jsp) elements which is part of main page(index.jsp) as DIV.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Collecting Values from remove div
 
Similar Threads
Struts2 variable inside javascript
List values are not bind with text fields
oracle database view+entity
<s:select in <s:iterate tag displaying with comma seperated value
spaces while populating using s:iterator