I am working on JSoup API in java to read the html content and get the link stored in the tag. Below is the html code, i want to get the link stored inside the following tag <a onClick="javascript:RefreshPageTo(event, "...)"> near <td class="ms-paging">1 - 15</td>; in the below html code.
html data to read the filenames:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN">
<html dir="ltr" class="ms-isBot" lang="en-US">
<head>
<meta name="GENERATOR" content="Microsoft SharePoint" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>
ALL ELP REPORTS
</title>
<!-- === Favicon / Windows Tile ==================================================================== -->
<link rel="shortcut icon" href=" " type="image/vnd.microsoft.icon" id="favicon" />
<meta name="msapplication-TileImage" content=" " />
<meta name="msapplication-TileColor" content="#0072C6" />
<script type="text/javascript" src=" "></script>
<link rel="stylesheet" type="text/css" href=" " />
<link id="CssRegistration1" rel="stylesheet" type="text/css" href=" " />
<link id="CssRegistration2" rel="stylesheet" type="text/css" href=" 0" />
<script type="text/javascript">CallASP("one.js");
</script>
<script type="text/javascript">RegisterSod("strings.js", "\u002f_layouts\u002f15\u002f1033\u002fstrings.js?rev=cG2ZohQxWuyz1\u00252BF2exRTjA\u00253D\u00253D");RegisterSodDep("strings.js", "initstrings.js");
<link type="text/xml" rel="alternate" href="/_asd.xls" />
<!-- Additional header placeholder =========================== -->
<link rel="alternate" type="application/rss+xml" title="Documents" href="/_layouts/15/listfeed.aspx?List=573d80cd%2D44f6%2D47b4%2D942f%2Da12a5a1841cb" />
<span id="analytics">
<script language="JavaScript" type="text/javascript">
<noscript>
<div class="noindex">
You may be trying to access this site from a secured browser on the server. Please enable scripts and reload this page.
</div>
</noscript>
<!-- ===== SP IDs / Prefetch SP images / SP Form =========================================================================== -->
<div id="imgPrefetch" style="display:none">
<img src="/_layouts/15/images/spcommon.png" />
</div>
<form method="post" action="./AllItems.aspx?RootFolder=%2fShared+Documents%2f08.Test+Report%2fMY20+Test+Reports%2fSanity%2fRaw+Data&FolderCTID=0x0120003C2FB175ACD9FE42B875BA259F53A6E3&View=%7bF8BC514C-49A5-47A2-8A6D-52DF70D61AE7%7d" id="aspnetForm">
<input type="hidden" name="_wpcmWpid" id="_wpcmWpid" value="" />
<input type="hidden" name="wpcmVal" id="wpcmVal" value="" />
<input type="hidden" name="MSOWebPartPage_PostbackSource" id="MSOWebPartPage_PostbackSource" value="" />
</script>
<div id="ctl00_ctl47_asdasd" class="asdaBrandMenu">
<!-- =============Suite Bar Links ======================-->
<div id="DeltaSuiteLinks" class="ms-core-deltaSuiteLinks">
<div id="suiteLinksBox">
<div id="SuiteLinksHidden" style="display: none">
</div>
<div id="launcherIconContainer">
</div>
<span style="display:none">
<menu type="ServerMenu" id="zz1_ID_PersonalActionMenu" hideicons="true">
<ie:menuitem id="zz2_ID_MyProfile" type="option" onmenuclick="" text="My Profile" menugroupid="100"></ie:menuitem>
<ie:menuitem id="zz3_ID_Logout" type="option" onmenuclick="" text="Sign Out" description="Logout of this site." menugroupid="100"></ie:menuitem>
</menu></span>
<span id="zz4_Menu_t" class="ms-menu-althov ms-welcome-root" title="Open Menu" onmouseover="MMU_PopMenuIfShowing(this);MMU_EcbTableMouseOverOut(this, true)" hoveractive="ms-menu-althov-active ms-welcome-root ms-welcome-hover" hoverinactive="ms-menu-althov ms-welcome-root" onclick=" CoreInvoke('MMU_Open',byid('zz1_ID_PersonalActionMenu'), MMU_GetMenuFromClientId('zz4_Menu'),event,true, null, 0); return false;" foa="MMU_GetMenuFromClientId('zz4_Menu')" oncontextmenu="ClkElmt(this); return false;" style="white-space:nowrap"><a class="ms-core-menu-root" id="zz4_Menu" accesskey="/" href="javascript:;" title="Open Menu" onfocus="MMU_EcbLinkOnFocusBlur(byid('zz1_ID_PersonalActionMenu'), this, true);" onkeydown="MMU_EcbLinkOnKeyDown(byid('zz1_ID_PersonalActionMenu'), MMU_GetMenuFromClientId('zz4_Menu'), event);" onclick=" CoreInvoke('MMU_Open',byid('zz1_ID_PersonalActionMenu'), MMU_GetMenuFromClientId('zz4_Menu'),event,true, null, 0); return false;" oncontextmenu="ClkElmt(this); return false;" menutokenvalues="MENUCLIENTID=zz4_Menu,TEMPLATECLIENTID=zz1_ID_PersonalActionMenu" serverclientid="zz4_Menu">Bhavani Borra<span class="ms-accessible">Use SHIFT+ENTER to open the menu (new window).</span></a><span style="height:4px;width:7px;position:relative;display:inline-block;overflow:hidden;" class="s4-clust ms-viewselector-arrow ms-menu-stdarw ms-core-menu-arrow"><img src="/_catalogs/theme/Themed/EB5E82F/spcommon-B35BB0A9.themedpng?ctag=3" alt="Open Menu" style="position:absolute;left:-95px !important;top:-259px !important;" /></span><span style="height:4px;width:7px;position:relative;display:inline-block;overflow:hidden;" class="s4-clust ms-core-menu-arrow ms-viewselector-arrow ms-menu-hovarw"><img src="/_catalogs/theme/Themed/EB5E82F/spcommon-B35BB0A9.themedpng?ctag=3" alt="Open Menu" style="position:absolute;left:-86px !important;top:-259px !important;" /></span></span>
</div>
<!-- ======== Start: Site Actions menu ============= -->
<div id="suiteBarButtons">
<span class="ms-siteactions-root" id="siteactiontd"> <span style="display:none">
<menu type="ServerMenu" id="zz5_FeatureMenuTemplate1" hideicons="true">
<ie:menuitem id="zz6_MenuItem_ShareThisSite" type="option" onmenuclick="" description="See who's here and invite new people." menugroupid="100"></ie:menuitem>
<ie:menuitem id="zz7_MenuItem_ViewAllSiteContents" type="option" iconsrc="" onmenuclick="STSNavigate2(event,'/_layouts/15/viewlsts.aspx');" text="Site contents" description="View all libraries and lists in this site." menugroupid="200"></ie:menuitem>
</menu></span><span id="zz8_SiteActionsMenu_t" class="ms-siteactions-normal" title="Settings" onmouseover="MMU_PopMenuIfShowing(this);MMU_EcbTableMouseOverOut(this, true)" hoveractive="ms-siteactions-normal ms-siteactions-hover" hoverinactive="ms-siteactions-normal">
<a class="ms-core-menu-root" id="zz8_SiteActionsMenu" accesskey="/" href="javascript:;" title="Settings" onkeydown="MMU_EcbLinkOnKeyDown(byid('zz5_FeatureMenuTemplate1'), MMU_GetMenuFromClientId('zz8_SiteActionsMenu'));" menutokenvalues="MENUCLIENTID=zz8_SiteActionsMenu,TEMPLATECLIENTID=zz5_FeatureMenuTemplate1" serverclientid="zz8_SiteActionsMenu"><span class="ms-siteactions-imgspan"><img class="ms-core-menu-buttonIcon" src="/_catalogs/theme/Themed/EB5E82F/Settings-white-94FE89A9.themedpng?ctag=3" alt="Settings" title="Settings" /></span><span class="ms-accessible">Use SHIFT+ENTER to open the menu (new window).</span></a></span> </span>
</div>
<!-- ================== End: Site Actions Menu ============================================ -->
<!-- ================== IT Help Link ============================================ -->
<div class="ms-core-listMenu-verticalBox">
</div>
</div>
</div>
</div>
<!-- ===== Main Content ========================================================================================== -->
<tr class="ms-alternating ms-itmhover" iid="47,1430,0">
<td class="ms-vb-itmcbx ms-vb-firstCell"><input type="checkbox" class="s4-itm-cbx" /></td>
<td class="ms-vb-icon"><img border="0" alt="ECS-dailyTask.xls" title="ECS-dailyTask.xls" src="" /></td>
<td height="100%" onmouseover="OnChildItem(this)" class="ms-vb-title">
<div class="ms-vb itx" onmouseover="OnItem(this)" ctxname="ctx47" id="1430" field="LinkFilename" perm="0x1b03c4312ef" eventtype="">
<a onfocus="OnLink(this)" href="/MyDocuments/ECS-dailyTask.xls" onmousedown="">ECS-dailyTask</a>
</div>
<div class="s4-ctx" onmouseover="OnChildItem(this.parentNode); return false;">
<span> </span>
<a onfocus="OnChildItem(this.parentNode.parentNode); return false;" onclick="" href="javascript:;" title="Open Menu"></a>
<span> </span>
</div></td>
<td class="ms-vb2">
<nobr>
3/31/2013 11:04 AM
</nobr></td>
<tr class="ms-alternating ms-itmhover" iid="47,1429,0">
<td class="ms-vb-itmcbx ms-vb-firstCell"><input type="checkbox" class="s4-itm-cbx" /></td>
<td class="ms-vb-icon"><img border="0" alt="ECS-MontlhyTask.xls" title="ECS-MontlhyTask.xls" src="/_layouts/15/images/icxls.png?rev=23" /></td>
<td height="100%" onmouseover="OnChildItem(this)" class="ms-vb-title">
<div class="ms-vb itx" onmouseover="OnItem(this)" ctxname="ctx47" id="1429" field="LinkFilename" perm="0x1b03c4312ef" eventtype="">
<a onfocus="OnLink(this)" href="/MyDocs/ECS-MontlhyTask.xls" onmousedown="">ECS-MontlhyTask</a>
</div>
<div class="s4-ctx" onmouseover="OnChildItem(this.parentNode); return false;">
<span> </span>
<a onfocus="" onclick="" href="javascript:;" title="Open Menu"></a>
<span> </span>
</div></td>
<td class="ms-vb2">
<nobr>
7/24/2016 10:09 PM
</nobr></td>
<td class="ms-vb-user"><span class="ms-noWrap"><span class="ms-imnSpan"><a href="#" onclick="" class="ms-imnlink ms-spimn-presenceLink">
<span class="ms-spimn-presenceWrapper ms-imnImg ms-spimn-imgSize-10x10">
<img name="imnmark" class="" title="" showofflinepawn="1" src="" alt="No presence information" id="imn_16532,type=sip" />
</span></a></span><span class="ms-noWrap ms-imnSpan">
<img name="imnmark" class="ms-hide" title="" showofflinepawn="1" src="" alt=""/>
<a class="ms-subtleLink" onclick="" href="/_layouts/15/userdisp.aspx?ID=113">ASDF</a></span></span></td>
</tr>
..
...
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="ms-bottompaging" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:pcm="urn:PageContentManager" xmlns:ddwrt2="urn:frontpage:internal">
<tbody>
<tr>
<td class="ms-bottompagingline1"><img src="/_images/11/images/blank.gif?rev=40" width="1" height="1" alt="" /></td>
</tr>
<tr>
<td class="ms-bottompagingline2"><img src="/_images/11/images/blank.gif?rev=40" width="1" height="1" alt="" /></td>
</tr>
<tr>
<td class="ms-vb" id="bottomPagingCellWPQ2" align="center">
<table>
<tbody>
<tr>
<td class="ms-paging">1 - 15</td>
<td><a onclick="javascript:RefreshPageTo(event, "/sites/myAppDetail/My%20Documents/Forms/AllApplicationss.aspx?Paged=TRUE&p_SortBehavior=0&p_FileLeafRef=LT%5fSW%20TEAM%5fNatural%5fItemCode%5f20170909%5fvstatus%2epdf&p_ID=85&RootFolder=%2fmyData%2fFolder3%2fCommon%20Docs%2fdaily%20Report%2f2017&PageFirstRow=16&&View={05465DFA-110E-21FC-8AD6-8B9846567FF8B}");javascript:return false;" href="javascript:"><img src="/_layouts/15/1011/images/next.gif" border="0" alt="Next" /></a></td>
</tr>
</tbody>
</table></td>
</tr>
<tr>
sample java code(not giving the expected output):
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import java.io.File;
import java.io.IOException;
public class ReadFileNamesFromHTMLContent {
public static void main(String args[]) throws IOException {
File input = new File("C:/jsoupTest/readData.html");
Document doc = Jsoup.parse(input, "UTF-8");
Elements links = doc.select(".ms-paging > td > a"); //get the value stored inside <a onClick="javascript:RefreshPageTo(event, "...)"> near <td class="ms-paging">1 - 15</td>;
System.out.println("size : "+ links.size()); //0
for (Element link : links) {
System.out.println(link);//empty, it should print the link
}
}
}
Output for the above code:
size:0
Expected output:
"/sites/myAppDetail/My%20Documents/Forms/AllApplicationss.aspx?Paged=TRUE&p_SortBehavior=0&p_FileLeafRef=LT%5fSW%20TEAM%5fNatural%5fItemCode%5f20170909%5fvstatus%2epdf&p_ID=85&RootFolder=%2fmyData%2fFolder3%2fCommon%20Docs%2fdaily%20Report%2f2017&PageFirstRow=16&&View={05465DFA-110E-21FC-8AD6-8B9846567FF8B}"
I think i'm missing some more conditional check to add to get the expected output.Any suggestions..
Your CSS selector is incorrect. It's looking for an <a> tag inside of a <td> tag inside of an .ms-paging class. The anchor tag you are interested in is not inside an ms-paging class.
Try changing your table row's HTML to this (add an ms-paging-row class):
<tr class="ms-paging-row">
<td class="ms-paging">1 - 15</td>
<td><a onclick="javascript:RefreshPageTo(event, "/sites/myAppDetail/My%20Documents/Forms/AllApplicationss.aspx?Paged=TRUE&p_SortBehavior=0&p_FileLeafRef=LT%5fSW%20TEAM%5fNatural%5fItemCode%5f20170909%5fvstatus%2epdf&p_ID=85&RootFolder=%2fmyData%2fFolder3%2fCommon%20Docs%2fdaily%20Report%2f2017&PageFirstRow=16&&View={05465DFA-110E-21FC-8AD6-8B9846567FF8B}");javascript:return false;" href="javascript:"><img src="/_layouts/15/1011/images/next.gif" border="0" alt="Next" /></a></td>
</tr>
And your Java code to this (change selector to .ms-paging-row > td > a):
File input = new File("C:/jsoupTest/readData.html");
Document doc = Jsoup.parse(input, "UTF-8");
Elements links = doc.select(".ms-paging-row > td > a"); //get the value stored inside <a onClick="javascript:RefreshPageTo(event, "...)"> near <td class="ms-paging">1 - 15</td>;
System.out.println("size : "+ links.size()); //0
for (Element link : links)
{
System.out.println(link);//empty, it should print the link
}
Update
If you cannot or do not wish to change the HTML, then just change your selector to use the adjacent combinator (plus sign): .ms-paging + td > a:
File input = new File("C:/jsoupTest/readData.html");
Document doc = Jsoup.parse(input, "UTF-8");
Elements links = doc.select(".ms-paging + td > a"); //get the value stored inside <a onClick="javascript:RefreshPageTo(event, "...)"> near <td class="ms-paging">1 - 15</td>;
System.out.println("size : "+ links.size()); //0
for (Element link : links)
{
System.out.println(link);//empty, it should print the link
}
Related
My Connection String
Class.forName("com.mysql.jdbc.Driver");
conn= DriverManager.getConnection("jdbc:mysql://localhost:3306/exam_system?useSSL=false&useUnicode=true&characterEncoding=utf8","root","Password");
My JSP File
<%#page import="java.util.ArrayList"%>
<jsp:useBean id="pDAO" class="myPackage.DatabaseClass" scope="page"/>
<%#page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="style-backend.css">
<link rel="stylesheet" type="text/css" href="style.css">
<meta charset="utf-8" >
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<label Style="color: black"> ছন্দে</label>
<input type="hidden" name="pgprt" value="4">
<select name="coursename" class="text">
<%
ArrayList list1=pDAO.getAllCourses();
for(int i=0;i<list1.size();i=i+2){
%>
<option value="<%=list1.get(i)%>"><%=list1.get(i)%></option>
<%
}
%>
</select>
<input type="submit" value="Show" class="form-button">
</form>
</div>
<div class="panel form-style-6" style="max-width: 420!important;float: right">
<form action="controller.jsp" >
<div class="title">Add New Question</div>
<table Style="color: black;font-color: black">
<tr>
<td><label Style="color: black">Course Name</label></td>
<td colspan="3">
<select name="coursename" class="text">
<%
ArrayList list=pDAO.getAllCourses();
for(int i=0;i<list.size();i=i+2){
%>
<option value="<%=list.get(i)%>"><%=list.get(i)%></option>
<%
} request.setCharacterEncoding("UTF-8");
%>
</select>
</td>
</tr>
<tr>
<td><label Style="color: black">Your Question:</label></td>
<td colspan="4"><input type="text" name="question" class="text" placeholder="Type your question here" style="width: 420px;" ></td><br>
</tr>
<tr>
<td><label Style="color: black">Options</label></td>
<td><input type="text" name="opt1" class="text" placeholder="First Option" style="width: 130px;" ></td>
<td><input type="text" name="opt2" class="text" placeholder="Second Option" style="width: 130px;" ></td>
<td><input type="text" name="opt3" class="text" placeholder="Third Option" style="width: 130px;" ></td>
<td><input type="text" name="opt4" class="text" placeholder="Fourth Option" style="width: 130px;" ></td>
</tr>
<tr>
<td><label>Correct Answer</label></td>
<td colspan="4"><center><input type="text" name="correct" class="text" placeholder="Correct Answer" style="width: 130px;" ></center></td>
<tr>
<td colspan="5"><input type="hidden" name="page" value="questions">
<input type="hidden" name="operation" value="addnew">
<center><input type="submit" class="form-button" value="Add" name="submit"></center></td>
When Inputting Non-English Data It is Not Inserting Correctly in MySQL Database. But
I changed Database Pattern And Test By Passing Non-English Data In String And It Works Perfectly.
INSERT INTO `exam_system`.`contact`
(`Name`,
`Email`,
`Message`)
VALUES
('<{Name:fsfsd }>',
'<{Email:sdfsdf }>',
'<{Message: 1. চর্যাপদ কোন ছন্দে লেখা? }');
Before Answering I tried
Net Bean Font Change
Tried Change String Data To Byte
And Rest
Change Are in the symbol Code.
When Accepting Parameter or User Value Convert That Value Into Char .
String crr=request.getParameter("correct");
byte[] bytesCrr = crr.getBytes(StandardCharsets.ISO_8859_1);
crr = new String(bytesCrr, StandardCharsets.UTF_8);
I am working on JSoup API in java to read the html content and get the link stored in the tag. Below is the html code, i want to get the link stored inside the following tag <a onClick="javascript:RefreshPageTo(event, "...)"> near <td class="ms-paging">1 - 15</td>; in the below html code.
html data to read the filenames (readData.html):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN">
<html dir="ltr" class="ms-isBot" lang="en-US">
<head>
<meta name="GENERATOR" content="Microsoft SharePoint" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>
ALL ELP REPORTS
</title>
<!-- === Favicon / Windows Tile ==================================================================== -->
<link rel="shortcut icon" href=" " type="image/vnd.microsoft.icon" id="favicon" />
<meta name="msapplication-TileImage" content=" " />
<meta name="msapplication-TileColor" content="#0072C6" />
<script type="text/javascript" src=" "></script>
<link rel="stylesheet" type="text/css" href=" " />
<link id="CssRegistration1" rel="stylesheet" type="text/css" href=" " />
<link id="CssRegistration2" rel="stylesheet" type="text/css" href=" 0" />
<script type="text/javascript">CallASP("one.js");
</script>
<script type="text/javascript">RegisterSod("strings.js", "\u002f_layouts\u002f15\u002f1033\u002fstrings.js?rev=cG2ZohQxWuyz1\u00252BF2exRTjA\u00253D\u00253D");RegisterSodDep("strings.js", "initstrings.js");
<link type="text/xml" rel="alternate" href="/_asd.xls" />
<!-- Additional header placeholder =========================== -->
<link rel="alternate" type="application/rss+xml" title="Documents" href="/_layouts/15/listfeed.aspx?List=573d80cd%2D44f6%2D47b4%2D942f%2Da12a5a1841cb" />
<span id="analytics">
<script language="JavaScript" type="text/javascript">
<noscript>
<div class="noindex">
You may be trying to access this site from a secured browser on the server. Please enable scripts and reload this page.
</div>
</noscript>
<!-- ===== SP IDs / Prefetch SP images / SP Form =========================================================================== -->
<div id="imgPrefetch" style="display:none">
<img src="/_layouts/15/images/spcommon.png" />
</div>
<form method="post" action="./AllItems.aspx?RootFolder=%2fShared+Documents%2f08.Test+Report%2fMY20+Test+Reports%2fSanity%2fRaw+Data&FolderCTID=0x0120003C2FB175ACD9FE42B875BA259F53A6E3&View=%7bF8BC514C-49A5-47A2-8A6D-52DF70D61AE7%7d" id="aspnetForm">
<input type="hidden" name="_wpcmWpid" id="_wpcmWpid" value="" />
<input type="hidden" name="wpcmVal" id="wpcmVal" value="" />
<input type="hidden" name="MSOWebPartPage_PostbackSource" id="MSOWebPartPage_PostbackSource" value="" />
</script>
<div id="ctl00_ctl47_asdasd" class="asdaBrandMenu">
<!-- =============Suite Bar Links ======================-->
<div id="DeltaSuiteLinks" class="ms-core-deltaSuiteLinks">
<div id="suiteLinksBox">
<div id="SuiteLinksHidden" style="display: none">
</div>
<div id="launcherIconContainer">
</div>
<span style="display:none">
<menu type="ServerMenu" id="zz1_ID_PersonalActionMenu" hideicons="true">
<ie:menuitem id="zz2_ID_MyProfile" type="option" onmenuclick="" text="My Profile" menugroupid="100"></ie:menuitem>
<ie:menuitem id="zz3_ID_Logout" type="option" onmenuclick="" text="Sign Out" description="Logout of this site." menugroupid="100"></ie:menuitem>
</menu></span>
<span id="zz4_Menu_t" class="ms-menu-althov ms-welcome-root" title="Open Menu" onmouseover="MMU_PopMenuIfShowing(this);MMU_EcbTableMouseOverOut(this, true)" hoveractive="ms-menu-althov-active ms-welcome-root ms-welcome-hover" hoverinactive="ms-menu-althov ms-welcome-root" onclick=" CoreInvoke('MMU_Open',byid('zz1_ID_PersonalActionMenu'), MMU_GetMenuFromClientId('zz4_Menu'),event,true, null, 0); return false;" foa="MMU_GetMenuFromClientId('zz4_Menu')" oncontextmenu="ClkElmt(this); return false;" style="white-space:nowrap"><a class="ms-core-menu-root" id="zz4_Menu" accesskey="/" href="javascript:;" title="Open Menu" onfocus="MMU_EcbLinkOnFocusBlur(byid('zz1_ID_PersonalActionMenu'), this, true);" onkeydown="MMU_EcbLinkOnKeyDown(byid('zz1_ID_PersonalActionMenu'), MMU_GetMenuFromClientId('zz4_Menu'), event);" onclick=" CoreInvoke('MMU_Open',byid('zz1_ID_PersonalActionMenu'), MMU_GetMenuFromClientId('zz4_Menu'),event,true, null, 0); return false;" oncontextmenu="ClkElmt(this); return false;" menutokenvalues="MENUCLIENTID=zz4_Menu,TEMPLATECLIENTID=zz1_ID_PersonalActionMenu" serverclientid="zz4_Menu">Bhavani Borra<span class="ms-accessible">Use SHIFT+ENTER to open the menu (new window).</span></a><span style="height:4px;width:7px;position:relative;display:inline-block;overflow:hidden;" class="s4-clust ms-viewselector-arrow ms-menu-stdarw ms-core-menu-arrow"><img src="/_catalogs/theme/Themed/EB5E82F/spcommon-B35BB0A9.themedpng?ctag=3" alt="Open Menu" style="position:absolute;left:-95px !important;top:-259px !important;" /></span><span style="height:4px;width:7px;position:relative;display:inline-block;overflow:hidden;" class="s4-clust ms-core-menu-arrow ms-viewselector-arrow ms-menu-hovarw"><img src="/_catalogs/theme/Themed/EB5E82F/spcommon-B35BB0A9.themedpng?ctag=3" alt="Open Menu" style="position:absolute;left:-86px !important;top:-259px !important;" /></span></span>
</div>
<!-- ======== Start: Site Actions menu ============= -->
<div id="suiteBarButtons">
<span class="ms-siteactions-root" id="siteactiontd"> <span style="display:none">
<menu type="ServerMenu" id="zz5_FeatureMenuTemplate1" hideicons="true">
<ie:menuitem id="zz6_MenuItem_ShareThisSite" type="option" onmenuclick="" description="See who's here and invite new people." menugroupid="100"></ie:menuitem>
<ie:menuitem id="zz7_MenuItem_ViewAllSiteContents" type="option" iconsrc="" onmenuclick="STSNavigate2(event,'/_layouts/15/viewlsts.aspx');" text="Site contents" description="View all libraries and lists in this site." menugroupid="200"></ie:menuitem>
</menu></span><span id="zz8_SiteActionsMenu_t" class="ms-siteactions-normal" title="Settings" onmouseover="MMU_PopMenuIfShowing(this);MMU_EcbTableMouseOverOut(this, true)" hoveractive="ms-siteactions-normal ms-siteactions-hover" hoverinactive="ms-siteactions-normal">
<a class="ms-core-menu-root" id="zz8_SiteActionsMenu" accesskey="/" href="javascript:;" title="Settings" onkeydown="MMU_EcbLinkOnKeyDown(byid('zz5_FeatureMenuTemplate1'), MMU_GetMenuFromClientId('zz8_SiteActionsMenu'));" menutokenvalues="MENUCLIENTID=zz8_SiteActionsMenu,TEMPLATECLIENTID=zz5_FeatureMenuTemplate1" serverclientid="zz8_SiteActionsMenu"><span class="ms-siteactions-imgspan"><img class="ms-core-menu-buttonIcon" src="/_catalogs/theme/Themed/EB5E82F/Settings-white-94FE89A9.themedpng?ctag=3" alt="Settings" title="Settings" /></span><span class="ms-accessible">Use SHIFT+ENTER to open the menu (new window).</span></a></span> </span>
</div>
<!-- ================== End: Site Actions Menu ============================================ -->
<!-- ================== IT Help Link ============================================ -->
<div class="ms-core-listMenu-verticalBox">
</div>
</div>
</div>
</div>
<!-- ===== Main Content ========================================================================================== -->
<tr class="ms-alternating ms-itmhover" iid="47,1430,0">
<td class="ms-vb-itmcbx ms-vb-firstCell"><input type="checkbox" class="s4-itm-cbx" /></td>
<td class="ms-vb-icon"><img border="0" alt="ECS-dailyTask.xls" title="ECS-dailyTask.xls" src="" /></td>
<td height="100%" onmouseover="OnChildItem(this)" class="ms-vb-title">
<div class="ms-vb itx" onmouseover="OnItem(this)" ctxname="ctx47" id="1430" field="LinkFilename" perm="0x1b03c4312ef" eventtype="">
<a onfocus="OnLink(this)" href="/MyDocuments/ECS-dailyTask.xls" onmousedown="">ECS-dailyTask</a>
</div>
<div class="s4-ctx" onmouseover="OnChildItem(this.parentNode); return false;">
<span> </span>
<a onfocus="OnChildItem(this.parentNode.parentNode); return false;" onclick="" href="javascript:;" title="Open Menu"></a>
<span> </span>
</div></td>
<td class="ms-vb2">
<nobr>
3/31/2013 11:04 AM
</nobr></td>
<tr class="ms-alternating ms-itmhover" iid="47,1429,0">
<td class="ms-vb-itmcbx ms-vb-firstCell"><input type="checkbox" class="s4-itm-cbx" /></td>
<td class="ms-vb-icon"><img border="0" alt="ECS-MontlhyTask.xls" title="ECS-MontlhyTask.xls" src="/_layouts/15/images/icxls.png?rev=23" /></td>
<td height="100%" onmouseover="OnChildItem(this)" class="ms-vb-title">
<div class="ms-vb itx" onmouseover="OnItem(this)" ctxname="ctx47" id="1429" field="LinkFilename" perm="0x1b03c4312ef" eventtype="">
<a onfocus="OnLink(this)" href="/MyDocs/ECS-MontlhyTask.xls" onmousedown="">ECS-MontlhyTask</a>
</div>
<div class="s4-ctx" onmouseover="OnChildItem(this.parentNode); return false;">
<span> </span>
<a onfocus="" onclick="" href="javascript:;" title="Open Menu"></a>
<span> </span>
</div></td>
<td class="ms-vb2">
<nobr>
7/24/2016 10:09 PM
</nobr></td>
<td class="ms-vb-user"><span class="ms-noWrap"><span class="ms-imnSpan"><a href="#" onclick="" class="ms-imnlink ms-spimn-presenceLink">
<span class="ms-spimn-presenceWrapper ms-imnImg ms-spimn-imgSize-10x10">
<img name="imnmark" class="" title="" showofflinepawn="1" src="" alt="No presence information" id="imn_16532,type=sip" />
</span></a></span><span class="ms-noWrap ms-imnSpan">
<img name="imnmark" class="ms-hide" title="" showofflinepawn="1" src="" alt=""/>
<a class="ms-subtleLink" onclick="" href="/_layouts/15/userdisp.aspx?ID=113">ASDF</a></span></span></td>
</tr>
..
...
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="ms-bottompaging" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:pcm="urn:PageContentManager" xmlns:ddwrt2="urn:frontpage:internal">
<tbody>
<tr>
<td class="ms-bottompagingline1"><img src="/_images/11/images/blank.gif?rev=40" width="1" height="1" alt="" /></td>
</tr>
<tr>
<td class="ms-bottompagingline2"><img src="/_images/11/images/blank.gif?rev=40" width="1" height="1" alt="" /></td>
</tr>
<tr>
<td class="ms-vb" id="bottomPagingCellWPQ2" align="center">
<table>
<tbody>
<tr>
<td class="ms-paging">1 - 15</td>
<td><a onclick="javascript:RefreshPageTo(event, "/sites/myAppDetail/My%20Documents/Forms/AllApplicationss.aspx?Paged=TRUE&p_SortBehavior=0&p_FileLeafRef=LT%5fSW%20TEAM%5fNatural%5fItemCode%5f20170909%5fvstatus%2epdf&p_ID=85&RootFolder=%2fmyData%2fFolder3%2fCommon%20Docs%2fdaily%20Report%2f2017&PageFirstRow=16&&View={05465DFA-110E-21FC-8AD6-8B9846567FF8B}");javascript:return false;" href="javascript:"><img src="/_layouts/15/1011/images/next.gif" border="0" alt="Next" /></a></td>
</tr>
</tbody>
</table></td>
</tr>
<tr>
sample java code(not giving the expected output):
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import java.io.File;
import java.io.IOException;
public class ReadFileNamesFromHTMLContent {
public static void main(String args[]) throws IOException {
File input = new File("readData.html");
Document doc = Jsoup.parse(input, "UTF-8");
Elements links = doc.select(".ms-paging > td > a"); //get the value stored inside <a onClick="javascript:RefreshPageTo(event, "...)"> near <td class="ms-paging">1 - 15</td>;
System.out.println("size : "+ links.size()); //0
for (Element link : links) {
System.out.println(link);//empty, it should print the link
}
}
}
Output for the above code:
size:0
Expected output:
"/sites/myAppDetail/My%20Documents/Forms/AllApplicationss.aspx?Paged=TRUE&p_SortBehavior=0&p_FileLeafRef=LT%5fSW%20TEAM%5fNatural%5fItemCode%5f20170909%5fvstatus%2epdf&p_ID=85&RootFolder=%2fmyData%2fFolder3%2fCommon%20Docs%2fdaily%20Report%2f2017&PageFirstRow=16&&View={05465DFA-110E-21FC-8AD6-8B9846567FF8B}"
Any suggestions on how to get the expected output would be helpful.
PS: Should not modify the html code.
Here is your HTML:
<td class="ms-paging">1 - 15</td>
<td><a onclick="javascript:RefreshPageTo(event, "/sites/myAppDetail/My%20Documents/Forms/AllApplicationss.aspx?Paged=TRUE&p_SortBehavior=0&p_FileLeafRef=LT%5fSW%20TEAM%5fNatural%5fItemCode%5f20170909%5fvstatus%2epdf&p_ID=85&RootFolder=%2fmyData%2fFolder3%2fCommon%20Docs%2fdaily%20Report%2f2017&PageFirstRow=16&&View={05465DFA-110E-21FC-8AD6-8B9846567FF8B}");javascript:return false;" href="javascript:"><img src="/_layouts/15/1011/images/next.gif" border="0" alt="Next" /></a></td>
But your selector is
Elements links = doc.select(".ms-paging > td > a");
However, the td element with the javascript onclick attribute is not a child of the td that you select. So you need to select only the links. Maybe try something like this:
Elements links = doc.select("td > a[onclick]");
I am parsing html document using Jsoup API in java. From the below shown html document i have filenames and time the file has created.
HTML document:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN">
<html dir="ltr" class="ms-isBot" lang="en-US">
<head>
<meta name="GENERATOR" content="Microsoft SharePoint" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>
ALL ELP REPORTS
</title>
<!-- === Favicon / Windows Tile ==================================================================== -->
<link rel="shortcut icon" href=" " type="image/vnd.microsoft.icon" id="favicon" />
<meta name="msapplication-TileImage" content=" " />
<meta name="msapplication-TileColor" content="#0072C6" />
<script type="text/javascript" src=" "></script>
<link rel="stylesheet" type="text/css" href=" " />
<link id="CssRegistration1" rel="stylesheet" type="text/css" href=" " />
<link id="CssRegistration2" rel="stylesheet" type="text/css" href=" 0" />
<script type="text/javascript">CallASP("one.js");
</script>
<script type="text/javascript">RegisterSod("strings.js", "\u002f_layouts\u002f15\u002f1033\u002fstrings.js?rev=cG2ZohQxWuyz1\u00252BF2exRTjA\u00253D\u00253D");RegisterSodDep("strings.js", "initstrings.js");
<link type="text/xml" rel="alternate" href="/_asd.xls" />
<!-- Additional header placeholder =========================== -->
<link rel="alternate" type="application/rss+xml" title="Documents" href="/_layouts/15/listfeed.aspx?List=573d80cd%2D44f6%2D47b4%2D942f%2Da12a5a1841cb" />
<span id="analytics">
<script language="JavaScript" type="text/javascript">
<noscript>
<div class="noindex">
You may be trying to access this site from a secured browser on the server. Please enable scripts and reload this page.
</div>
</noscript>
<!-- ===== SP IDs / Prefetch SP images / SP Form =========================================================================== -->
<div id="imgPrefetch" style="display:none">
<img src="/_layouts/15/images/spcommon.png" />
</div>
<form method="post" action="./AllItems.aspx?RootFolder=%2fShared+Documents%2f08.Test+Report%2fMY20+Test+Reports%2fSanity%2fRaw+Data&FolderCTID=0x0120003C2FB175ACD9FE42B875BA259F53A6E3&View=%7bF8BC514C-49A5-47A2-8A6D-52DF70D61AE7%7d" id="aspnetForm">
<input type="hidden" name="_wpcmWpid" id="_wpcmWpid" value="" />
<input type="hidden" name="wpcmVal" id="wpcmVal" value="" />
<input type="hidden" name="MSOWebPartPage_PostbackSource" id="MSOWebPartPage_PostbackSource" value="" />
</script>
<div id="ctl00_ctl47_asdasd" class="asdaBrandMenu">
<!-- =============Suite Bar Links ======================-->
<div id="DeltaSuiteLinks" class="ms-core-deltaSuiteLinks">
<div id="suiteLinksBox">
<div id="SuiteLinksHidden" style="display: none">
</div>
<div id="launcherIconContainer">
</div>
<span style="display:none">
<menu type="ServerMenu" id="zz1_ID_PersonalActionMenu" hideicons="true">
<ie:menuitem id="zz2_ID_MyProfile" type="option" onmenuclick="" text="My Profile" menugroupid="100"></ie:menuitem>
<ie:menuitem id="zz3_ID_Logout" type="option" onmenuclick="" text="Sign Out" description="Logout of this site." menugroupid="100"></ie:menuitem>
</menu></span>
<span id="zz4_Menu_t" class="ms-menu-althov ms-welcome-root" title="Open Menu" onmouseover="MMU_PopMenuIfShowing(this);MMU_EcbTableMouseOverOut(this, true)" hoveractive="ms-menu-althov-active ms-welcome-root ms-welcome-hover" hoverinactive="ms-menu-althov ms-welcome-root" onclick=" CoreInvoke('MMU_Open',byid('zz1_ID_PersonalActionMenu'), MMU_GetMenuFromClientId('zz4_Menu'),event,true, null, 0); return false;" foa="MMU_GetMenuFromClientId('zz4_Menu')" oncontextmenu="ClkElmt(this); return false;" style="white-space:nowrap"><a class="ms-core-menu-root" id="zz4_Menu" accesskey="/" href="javascript:;" title="Open Menu" onfocus="MMU_EcbLinkOnFocusBlur(byid('zz1_ID_PersonalActionMenu'), this, true);" onkeydown="MMU_EcbLinkOnKeyDown(byid('zz1_ID_PersonalActionMenu'), MMU_GetMenuFromClientId('zz4_Menu'), event);" onclick=" CoreInvoke('MMU_Open',byid('zz1_ID_PersonalActionMenu'), MMU_GetMenuFromClientId('zz4_Menu'),event,true, null, 0); return false;" oncontextmenu="ClkElmt(this); return false;" menutokenvalues="MENUCLIENTID=zz4_Menu,TEMPLATECLIENTID=zz1_ID_PersonalActionMenu" serverclientid="zz4_Menu">Bhavani Borra<span class="ms-accessible">Use SHIFT+ENTER to open the menu (new window).</span></a><span style="height:4px;width:7px;position:relative;display:inline-block;overflow:hidden;" class="s4-clust ms-viewselector-arrow ms-menu-stdarw ms-core-menu-arrow"><img src="/_catalogs/theme/Themed/EB5E82F/spcommon-B35BB0A9.themedpng?ctag=3" alt="Open Menu" style="position:absolute;left:-95px !important;top:-259px !important;" /></span><span style="height:4px;width:7px;position:relative;display:inline-block;overflow:hidden;" class="s4-clust ms-core-menu-arrow ms-viewselector-arrow ms-menu-hovarw"><img src="/_catalogs/theme/Themed/EB5E82F/spcommon-B35BB0A9.themedpng?ctag=3" alt="Open Menu" style="position:absolute;left:-86px !important;top:-259px !important;" /></span></span>
</div>
<!-- ======== Start: Site Actions menu ============= -->
<div id="suiteBarButtons">
<span class="ms-siteactions-root" id="siteactiontd"> <span style="display:none">
<menu type="ServerMenu" id="zz5_FeatureMenuTemplate1" hideicons="true">
<ie:menuitem id="zz6_MenuItem_ShareThisSite" type="option" onmenuclick="" description="See who's here and invite new people." menugroupid="100"></ie:menuitem>
<ie:menuitem id="zz7_MenuItem_ViewAllSiteContents" type="option" iconsrc="" onmenuclick="STSNavigate2(event,'/_layouts/15/viewlsts.aspx');" text="Site contents" description="View all libraries and lists in this site." menugroupid="200"></ie:menuitem>
</menu></span><span id="zz8_SiteActionsMenu_t" class="ms-siteactions-normal" title="Settings" onmouseover="MMU_PopMenuIfShowing(this);MMU_EcbTableMouseOverOut(this, true)" hoveractive="ms-siteactions-normal ms-siteactions-hover" hoverinactive="ms-siteactions-normal">
<a class="ms-core-menu-root" id="zz8_SiteActionsMenu" accesskey="/" href="javascript:;" title="Settings" onkeydown="MMU_EcbLinkOnKeyDown(byid('zz5_FeatureMenuTemplate1'), MMU_GetMenuFromClientId('zz8_SiteActionsMenu'));" menutokenvalues="MENUCLIENTID=zz8_SiteActionsMenu,TEMPLATECLIENTID=zz5_FeatureMenuTemplate1" serverclientid="zz8_SiteActionsMenu"><span class="ms-siteactions-imgspan"><img class="ms-core-menu-buttonIcon" src="/_catalogs/theme/Themed/EB5E82F/Settings-white-94FE89A9.themedpng?ctag=3" alt="Settings" title="Settings" /></span><span class="ms-accessible">Use SHIFT+ENTER to open the menu (new window).</span></a></span> </span>
</div>
<!-- ================== End: Site Actions Menu ============================================ -->
<!-- ================== IT Help Link ============================================ -->
<div class="ms-core-listMenu-verticalBox">
</div>
</div>
</div>
</div>
<!-- ===== Main Content ========================================================================================== -->
<tr class="ms-alternating ms-itmhover" iid="47,1430,0">
<td class="ms-vb-itmcbx ms-vb-firstCell"><input type="checkbox" class="s4-itm-cbx" /></td>
<td class="ms-vb-icon"><img border="0" alt="ECS-dailyTask.xls" title="ECS-dailyTask.xls" src="" /></td>
<td height="100%" onmouseover="OnChildItem(this)" class="ms-vb-title">
<div class="ms-vb itx" onmouseover="OnItem(this)" ctxname="ctx47" id="1430" field="LinkFilename" perm="0x1b03c4312ef" eventtype="">
<a onfocus="OnLink(this)" href="/MyDocuments/ECS-dailyTask.xls" onmousedown="">ECS-dailyTask</a>
</div>
<div class="s4-ctx" onmouseover="OnChildItem(this.parentNode); return false;">
<span> </span>
<a onfocus="OnChildItem(this.parentNode.parentNode); return false;" onclick="" href="javascript:;" title="Open Menu"></a>
<span> </span>
</div></td>
<td class="ms-vb2">
<nobr>
3/31/2013 11:04 AM
</nobr></td>
<tr class="ms-alternating ms-itmhover" iid="47,1429,0">
<td class="ms-vb-itmcbx ms-vb-firstCell"><input type="checkbox" class="s4-itm-cbx" /></td>
<td class="ms-vb-icon"><img border="0" alt="ECS-MontlhyTask.xls" title="ECS-MontlhyTask.xls" src="/_layouts/15/images/icxls.png?rev=23" /></td>
<td height="100%" onmouseover="OnChildItem(this)" class="ms-vb-title">
<div class="ms-vb itx" onmouseover="OnItem(this)" ctxname="ctx47" id="1429" field="LinkFilename" perm="0x1b03c4312ef" eventtype="">
<a onfocus="OnLink(this)" href="/MyDocs/ECS-MontlhyTask.xls" onmousedown="">ECS-MontlhyTask</a>
</div>
<div class="s4-ctx" onmouseover="OnChildItem(this.parentNode); return false;">
<span> </span>
<a onfocus="" onclick="" href="javascript:;" title="Open Menu"></a>
<span> </span>
</div></td>
<td class="ms-vb2">
<nobr>
7/24/2016 10:09 PM
</nobr></td>
<td class="ms-vb-user"><span class="ms-noWrap"><span class="ms-imnSpan"><a href="#" onclick="" class="ms-imnlink ms-spimn-presenceLink">
<span class="ms-spimn-presenceWrapper ms-imnImg ms-spimn-imgSize-10x10">
<img name="imnmark" class="" title="" showofflinepawn="1" src="" alt="No presence information" id="imn_16532,type=sip" />
</span></a></span><span class="ms-noWrap ms-imnSpan">
<img name="imnmark" class="ms-hide" title="" showofflinepawn="1" src="" alt=""/>
<a class="ms-subtleLink" onclick="" href="/_layouts/15/userdisp.aspx?ID=113">ASDF</a></span></span></td>
</tr>
java code:
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import java.io.File;
import java.io.IOException;
public class FileNamesRead {
public static void main(String args[]) throws IOException {
File input = new File("C:/htmlDocs/myDoc.html");
Document doc = Jsoup.parse(input, "UTF-8");
Elements tds = doc.select("div.ms-vb, .itx");
for (Element td : tds) {
System.out.println("The file class is: " + td.select("a").text());
}
Elements td1s = doc.select("nobr"); //select tag nobr
for (Element td : td1s) {
System.out.println("The date is: " + td.text());
}
}
Output:
The file class is: ECS-dailyTask
The file class is: ECS-MontlhyTask
The date is: 3/31/2013 11:04 AM
The date is: 7/24/2016 10:09 PM
Expected output:
ECS-MontlhyTask
I want the latest uploaded filename to be returned instead of displaying all file names. How can i get the latest uploaded filename checked based on timestamp. Please advice. From my side i was trying to keep the file name and time in a List object, iterate compare the file associated time with Timestamp and return the latest file. Is there any better approach. My html document returns a huge list of filenames and its time(around 100+ filenames).
I have completed HTML project and works find and no ERROR
Now my problem is that I am unable to find incomplete job in my Project. I use Netbeans for creating this project is there a way to find any incomplete work in existing project?
I used HTML, Flash, java, to create this entire project. Is there a tool to find this incomplete work or can I find it using Netbeans
So, how do I find incomplete work?
Thanks in advance
CODE
<!DOCTYPE html>
<html>
<head>
<title>Atomic Structure and Chemical Bonds</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link type='text/css' rel='stylesheet' href='assets/css/bootstrap.min.css' />
<link type='text/css' rel='stylesheet' href='assets/css/VLAB.css' />
<link type='text/css' rel='stylesheet' href='assets/css/E20.css' />
<!--<link type='text/css' rel='stylesheet' href='assets/css/bootstrap-theme.min.css' />-->
<!--for Font-->
<link rel="stylesheet" type="text/css" media="screen" href="assets/fonts/webfontkit_proximaNova_reg/ProximaNova-Regular.css" />
<link rel="stylesheet" type="text/css" media="screen" href="assets/fonts/webfontkit_proximanova_sb/ProximaNova-Semibold.css" />
<script src="assets/js/jquery-1.9.1.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script type="text/javascript" src="assets/js/jquery-ui.min.js"></script>
<script type="text/javascript" src="assets/js/jquery.ui.touch-punch.js"></script>
<script type="text/javascript" src="assets/js/jquery.shuffle.js"></script>
<script type="text/javascript" src="assets/js/calc.js"></script>
<!-- Icon Assets -->
<script type="text/javascript" src="assets/js/journal.js"></script>
<script type="text/javascript" src="assets/js/sound.js"></script>
<script type="text/javascript" src="assets/js/print.js"></script>
<script type="text/javascript" src="assets/js/main.js"></script>
<script type="text/javascript">
function incrementButtons( upBtn, downBtn, qtyField )
{
var step = parseFloat( qtyField.value ) || 1,
currentValue = step;
downBtn.onclick = function()
{
currentValue = parseFloat( qtyField.value ) || step;
qtyField.value = ( currentValue -= Math.min( step, currentValue - step ) );
}
upBtn.onclick = function()
{
currentValue = parseFloat( qtyField.value ) || step;
qtyField.value = ( currentValue += step );
}
}
</script>
</head>
<body>
<div class="overlay"></div>
<div class="VLAB_container">
<header>
<div class="VLAB_head">VIRTUAL LABS</div>
<div class="VLAB_exit">X</div>
<div class="VLAB_print"></div>
<div class="VLAB_audio"></div>
</header>
<!-- Table Popup -->
<div id="VLAB_table" class="VLAB_table"
style="display:none;z-index:101;">
<div class="VLAB_table_title">Table <div class="VLAB_table_exit">X</div></div>
<div class="VLAB_table_subtitle">Title here </div>
<br/>
<div>
<table id="answered">
<thead>
<tr>
<th>Value 1</th>
<th>Value 2</th>
<th>Value 3</th>
<th>Value 4</th>
</tr>
</thead>
<tbody>
<tr>
<td data-id="all"><input type='text' value='' /></td>
<td data-id="all"><input type='text' value='' /></td>
<td data-id="all"><input type='text' value='' /></td>
<td data-id="all"><input type='text' value='' /></td>
</tr>
<tr>
<td data-id="all"><input type='text' value='' /></td>
<td data-id="all"><input type='text' value='' /></td>
<td data-id="all"><input type='text' value='' /></td>
<td data-id="all"><input type='text' value='' /></td>
</tr>
<tr>
<td data-id="all"><input type='text' value='' /></td>
<td data-id="all"><input type='text' value='' /></td>
<td data-id="all"><input type='text' value='' /></td>
<td data-id="all"><input type='text' value='' /></td>
</tr>
</tbody>
</table>
</div>
<div class="VLAB_table_buttons">
<button type="button" class="btn disabled">Graph</button>
<button type="button" class="btn">Save</button>
<button type="button" class="btn">Print</button>
</div>
</div>
<!-- Table Popup ENDS-->
<!-- Journal Popup-->
<div id="VLAB_journal" class="VLAB_journal" style="display:none;z-index:101;">
<div class="VLAB_journal_title">Journal <div class="VLAB_journal_navigation"><div class="VLAB_journal_exit">X</div>
<div class="VLAB_journal_next"></div>
<span class="VLAB_journal_Qno"></span>
<div class="VLAB_journal_prev"></div>
</div>
</div>
<div class="VLAB_journal_subtitle"></div>
<div id="journalQuestions" style="display:none;z-index:101;">
<form action="#" class="regform" method="get">
<p>What part of the digestive system would you see in a cross-section anterior to the gizzard?<br/>
<textarea class="VLAB_journal_text_area" id="Answer1"
name="Question1" placeholder=""></textarea></p>
<p>What structure in the earthworm has a similar function as the human heart? Explain your answer.<br/>
<textarea class="VLAB_journal_text_area" id="Answer2"
name="Question2" placeholder=""></textarea></p>
<p>What do two earthworms exchange during mating? Explain your answer.<br/>
<textarea class="VLAB_journal_text_area" id="Answer3"
name="Question3" placeholder=""></textarea></p>
<p>Describe the difference between a closed and an open circulatory system.<br/>
<textarea class="VLAB_journal_text_area" id="Answer4"
name="Question4" placeholder=""></textarea></p>
<p>Do earthworms have a front and a back end? Explain your answer.<br/>
<textarea class="VLAB_journal_text_area" id="Answer5"
name="Question5" placeholder=""></textarea></p>
<p>What characteristics distinguish an annelid from other worms?<br/>
<textarea class="VLAB_journal_text_area" id="Answer6"
name="Question6" placeholder=""></textarea></p>
</form>
</div>
<div class="VLAB_journal_buttons">
<button type="button" class="btn">Save</button>
<button id="journalPrint" type="button" class="btn">Print</button>
</div>
</div>
<!-- Journal Popup ENDS-->
<!-- AUDIO START -->
<div style="display:none;">
<audio preload="metadata" id="a1" class="a1">
<source class="aud_src" src="assets/audio/sound2drag.mp3" type = "audio/mp3">
<source class="aud_src" src="assets/audio/sound2drag.ogg" type = "audio/ogg">
</audio>
</div>
<!-- AUDIO END -->
<!-- Calculator -->
<form>
<div class="VLAB_CALC">
<div class="VLAB_CALC_title">Calculator
<div class="VLAB_CALC_exit">X</div>
</div>
<div class="VLAB_CALC_screen">
<input type="text" id="memory" class="pull-left" value="" readonly /> <input type="text" id="displayPanel" class="pull-right" value="0" readonly /> </div>
<div class="VLAB_CALC_buttonpad">
<div class="dark" onclick='ac()'>AC</div>
<div class="dark" onclick='ce()'>CE/C</div>
<div class="dark" onclick='perc()' > %</div>
<div class="dark right" onclick='getoperator("/")'>/</div>
<div onclick='getdigit("1")'>1</div>
<div onclick='getdigit("2")'>2</div>
<div onclick='getdigit("3")'>3</div>
<div class="dark right" onclick='getoperator("*")'>×</div>
<div onclick='getdigit("4")'>4</div>
<div onclick='getdigit("5")'>5</div>
<div onclick='getdigit("6")'>6</div>
<div class="dark right" onclick='getoperator("+")'>+</div>
<div onclick='getdigit("7")'>7</div>
<div onclick='getdigit("8")'>8</div>
<div onclick='getdigit("9")'>9</div>
<div class="dark right" onclick='getoperator("-")'>−</div>
<div onclick='getdigit("0")'>0</div>
<div class="dark" onclick='v(".")'>.</div>
<div class="dark right equal-sign" onclick='e()'>=</div>
<div class="dark lastrow" onclick='sto()' >STO</div>
<div class="dark lastrow" id="memoryBtn" onclick='rcl()'>RCL</div>
<div class="dark right lastrow" onclick=' sum_m()'>SUM</div>
</div>
</div>
</form>
<!-- Calculator END -->
<div id="VLAB_leftPanel" class="VLAB_leftPanel">
<div class="VLAB_leftPanel_head">Measurements</div>
<div class="VLAB_leftPanel_subhead">What are the structures and body systems of an earthworm?</div>
<div class="VLAB_leftPanel_content">
<p>We study earthworms to learn the structures and functions of segmented worms, also called annelids. Segmentation supports diversified functions of body parts and tissues. Studying the anatomy and body systems of annelids helps us understand the bodies of higher-level organisms. <br/><br/>Earthworms are classified in the phylum <i>Annelida</i>. (Kingdom: Animal; Phylum; Annelida; Class: Oligochaeta; Order: Opisthopora; Family: Lumbricidae; Genus: <i>Lumbricus</i>; Species:<i>Lumbricus terrestris</i>) The Annelida also include leeches and bristleworms. Segmented worms have bilateral symmetry and have a coelom, which is a fluid-filled body cavity surrounded by mesoderm. Earthworms have two body openings, a mouth and an anus. The basic body plan of segmented worms consists of a digestive tract within a tube. Earthworms are hermaphrodites, which means that an individual animal produces both sperm and eggs. During mating, two earthworms exchange sperm. Each earthworm forms a capsule for the eggs and sperm in which the eggs are fertilized. The capsule is left behind in the soil where the young earthworms emerge from the eggs in two to three weeks. Earthworms are herbivores. They obtain food by eating through the soil and extracting nutrients from it as food passes through the digestive tract. As an earthworm burrows, it loosens, aerates, and fertilizes the soil. Earthworm burrows provide passageways for plant roots and improve drainage of the soil.<br/><br/>
<b>Procedure</b><br/><br/> <b>1</b>. Click the <b>Lab manual</b> to read about earthworm anatomy.<br/><br/><b>2</b>. Click the <b>External anatomy button</b> to view a diagram of the external features of an earthworm.<br/><br/><b>3</b>. Drag and drop the <b>Labels</b> to the matching structures of the illustration.<br/><br/><b>4</b>. When all structures are labeled, the <b>Check button</b> is enabled. Click the <b>Check button</b> to receive feedback on whether the labels are matched with the correct structures. Correct the highlighted incorrect labels.<br/><br/><b>5</b>. Click the <b>Internal anatomy button</b> to view a diagram of the internal features of the earthworm and repeat steps 3 and 4.<br/><br/><b>6</b>. Answer the <b>Journal Questions</b>.</p>
</div>
<div class="VLAB_leftPanel_buttons">
<button id="journalBtn" type="button" class="btn">Journal</button>
<button id="calcBtn" type="button" class="btn">Calculator</button>
<button id="tableBtn" type="button" class="btn">Table</button>
</div>
</div>
<!-- right Panel for Interactivity part-->
<div class="VLAB_rightPanel">
<div id="page_content">
<div id="vlab_assets">
<!-- for development -->
<div calss="lab"><img height="683" width="700" src="assets/img/main.png" alt="image" style="position:absolute;"/></div>
<div style="position:absolute;margin-left:12px;margin-top:101px;"><img height="545" width="667" src="assets/img/bg_yellow.png" alt="image" style="position:absolute;"/></div>
<button id="me1" class="button">Hydrogen</button>
<button id="me2" class="button" style="margin-left:184px;">Hydrogen</button>
<button id="me3" class="button" style="margin-left:348px;">Hydrogen</button>
<button id="me4" class="button" style="margin-left:512px;width:160px;">Hydrogen</button>
<!--a class="term" id="pop1"><button class="buttona" style="margin-top:113px;margin-left:530px;width:122px;height:30px;">Show Labels</button></a-->
<script language="javascript">
var _0xd7e2=["\x6D\x61\x74\x63\x68","\x75\x73\x65\x72\x41\x67\x65\x6E\x74","\x74\x6F\x75\x63\x68\x73\x74\x61\x72\x74","\x63\x6C\x69\x63\x6B","\x6E\x6F\x43\x6F\x6E\x66\x6C\x69\x63\x74","\x68\x69\x64\x65","\x2E\x41\x6E\x73\x5F\x31\x50\x6F\x70","\x66\x61\x64\x65\x54\x6F\x67\x67\x6C\x65","\x73\x70\x61\x6E","\x63\x68\x69\x6C\x64\x72\x65\x6E","\x2E\x41\x6E\x73\x5F\x31","\x76\x61\x6C","\x53\x68\x6F\x77","\x48\x69\x64\x65","\x62\x69\x6E\x64","\x23\x62\x74\x6E\x53\x68\x6F\x77","\x72\x65\x61\x64\x79"];var what=(navigator[_0xd7e2[1]][_0xd7e2[0]](/iPad/i))?_0xd7e2[2]:_0xd7e2[3];var $=jQuery[_0xd7e2[4]]();$(document)[_0xd7e2[16]](function (_0xf214x3){$(_0xd7e2[6])[_0xd7e2[5]]();$(_0xd7e2[15])[_0xd7e2[14]](what,function (_0xf214x3){var _0xf214x4=$(this);$(_0xd7e2[10])[_0xd7e2[9]](_0xd7e2[8])[_0xd7e2[7]]();_0xf214x4[_0xd7e2[11]](_0xf214x4[_0xd7e2[11]]()==_0xd7e2[12]?_0xd7e2[13]:_0xd7e2[12]);} );} );
</script>
<script type="text/javascript" src="assets/js/jquery.1.10.2.min.js"></script>
<div class="Ans_1" style="position:absolute;margin-top:160px;margin-left:23px;opacity:1;">
<span style="opacity:1;" class="Ans_1Pop" ><img height="410" width="490" src="assets/img/label.png" alt="image"/></span>
</div>
<input type="button" id="btnShow" value="Show Labels" style="position:absolute;margin-top:113px;margin-left:530px;width:122px;height:30px;" />
<form id="f1" style="position:absolute;">
<p><input class="form-control transparent-input" type='text' name='qty' id='qty' value='0' readonly='readonly' style="position:absolute;font-family:verdana;font-weight:bold;margin-top:295px;margin-left:240px;width:55px;height:40px;border:black;background:black;color:white;text-align:center;"/></p>
<p><input type='button' name='add' value='' style="margin-top:277px;margin-left:317px;position:absolute;width:20px;height10px;opacity:0;"/></p>
<p><input type='button' name='subtract' value='' style="margin-top:305px;margin-left:317px;position:absolute;width:20px;height10px;opacity:0;"/></p>
</form>
<script type="text/javascript">
with( document.getElementById( 'f1' ) )
incrementButtons( add, subtract, qty );
</script>
<form id="f2" style="position:absolute;">
<p><input class="form-control transparent-input" type='text' name='qty' id='qty' value='0' readonly='readonly' style="position:absolute;font-family:verdana;font-weight:bold;margin-top:350px;margin-left:240px;width:55px;height:40px;border:black;background:black;color:white;text-align:center;"/></p>
<p><input type='button' name='add' value='' style="position:absolute;margin-top:347px;margin-left:317px;width:20px;height:20px;opacity:0;"/></p>
<p><input type='button' name='subtract' value='' style="position:absolute;margin-top:369px;margin-left:317px;width:20px;height:20px;opacity:0;"/></p>
</form>
<script type="text/javascript">
with( document.getElementById( 'f2' ) )
incrementButtons( add, subtract, qty );
</script>
<button id="check" class="buttona" style="margin-top:494px;margin-left:535px;width:102px;height:30px;">Check</button>
<form id="f3" style="position:absolute;">
<p><input class="form-control transparent-input" type='text' name='qty' id='qty' value='0' readonly='readonly' style="position:absolute;font-family:verdana;font-weight:bold;margin-top:574px;margin-left:342px;width:55px;height:40px;border:black;background:black;color:white;text-align:right;"/></p>
<p><input type='button' name='add' value='' style="position:absolute;margin-top:571px;margin-left:407px;width:12px;height:12px;opacity:0;"/></p>
<p><input type='button' name='subtract' value='' style="position:absolute;margin-top:586px;margin-left:407px;width:12px;height:12px;opacity:0;"/></p>
</form>
<script type="text/javascript">
with( document.getElementById( 'f3' ) )
incrementButtons( add, subtract, qty );
</script>
<form id="f4" style="position:absolute;">
<p><input class="form-control transparent-input" type='text' name='qty' id='qty' value='0' readonly='readonly' style="position:absolute;font-family:verdana;font-weight:bold;margin-top:574px;margin-left:428px;width:55px;height:40px;border:black;background:black;color:white;text-align:right;"/></p>
<p><input type='button' name='add' value='' style="position:absolute;margin-top:571px;margin-left:493px;width:12px;height:12px;opacity:0;"/></p>
<p><input type='button' name='subtract' value='' style="position:absolute;margin-top:586px;margin-left:493px;width:12px;height:12px;opacity:0;"/></p>
</form>
<script type="text/javascript">
with( document.getElementById( 'f4' ) )
incrementButtons( add, subtract, qty );
</script>
<form id="f5" style="position:absolute;">
<p><input class="form-control transparent-input" type='text' name='qty' id='qty' value='0' readonly='readonly' style="position:absolute;font-family:verdana;font-weight:bold;margin-top:574px;margin-left:513px;width:55px;height:40px;border:black;background:black;color:white;text-align:right;"/></p>
<p><input type='button' name='add' value='' style="position:absolute;margin-top:572px;margin-left:580px;width:12px;height:12px;opacity:0;"/></p>
<p><input type='button' name='subtract' value='' style="position:absolute;margin-top:586px;margin-left:580px;width:12px;height:12px;opacity:0;"/></p>
</form>
<script type="text/javascript">
with( document.getElementById( 'f5' ) )
incrementButtons( add, subtract, qty );
</script>
<div id="basic-modal-content" style="position:absolute;margin-top:221px;margin-left:132px;z-index:0;">
<img width="395" height="320" src="assets/img/video1.png" alt="image" />
</div>
<input type="button" id="video" class="buttona" style="margin-top:596px;margin-left:61px;width:80px;height:31px;" value="Video" />
<div id="video" style="position:absolute;margin-top:227px;margin-left:165px;z-index:1;">
<video id="video1" width="330" height="294" autoplay>
<source src="assets/audio/E20.mp4" type="video/mp4" />
<source src="assets/audio/E20.ogg" type="video/ogg" />
<source src="assets/audio/E20.webm" type="video/webm" />
Your browser does not support the video element.
</video></div>
<button id="reset" class="buttona" style="margin-top:596px;margin-left:184px;width:80px;height:31px;">Reset</button>
</div>
</div>
</div>
</div><!--End VLab Container-->
</body>
</html>
Unless the "incomplete work" / "incomplete job" is something that won't compile OR is flagged in the source code with "FIX ME" or "TO DO" tags (or the like), then I don't see how NetBeans or any other tool could distinguish between what is incomplete, and what is not.
There are tools that can detect some kinds of bug by analysing the source code, but I don't expect that that is what you mean by "incomplete".
Hi all I have (just like the rest) inherited some struts 1 code. I have had need to add a few more pages to this project.
What I cannot figure out is how to map several distinct but similarly natured input elements to my ActionForm.
Let me elaborate. I create a new <Input> element dynamically as the user inputs more and more items (I use the YUI autocomplete form element and for each entered input I add it as an input element to my form and draw a new YUI autocomplete - complex sounding, I know)
So... My form looks a bit like (... after some prettifying and some such...):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>My Cool App - Test Case Builder</title>
<link rel="stylesheet" type="text/css" href="../script/yui/fonts/fonts-min.css" />
<link rel="stylesheet" type="text/css" href="../skins/myCoolApp/button/button.css" />
<link rel="stylesheet" type="text/css" href="../script/yui/autocomplete/assets/skins/sam/autocomplete.css" />
<link rel="stylesheet" type="text/css" media="screen" href="../skins/myCoolApp/testcase.css" />
<!-- YUI JAVA SCRIPTS -->
<script type="text/javascript" src="../script/yui/yahoo-dom-event/yahoo-dom-event.js"></script>
<script type="text/javascript" src="../script/yui/element/element-min.js"></script>
<script type="text/javascript" src="../script/yui/button/button-min.js"></script>
<script type="text/javascript" src="../script/yui/datasource/datasource-min.js"></script>
<script type="text/javascript" src="../script/yui/autocomplete/autocomplete-min.js"></script>
<!-- APP JAVA SCRIPTS -->
<script type="text/javascript" src="../script/myCoolApp/myCoolApp.js" ></script>
<script type="text/javascript" src="../script/myCoolApp/stack.js" ></script>
<script type="text/javascript" src="../script/myCoolApp/testcase/testcase.js"></script>
<script type="text/javascript" src="../script/myCoolApp/testcase/default-data.js" ></script>
<script type="text/javascript" src="../script/myCoolApp/testcase/data-structs.js" ></script>
<script type="text/javascript" src="../script/myCoolApp/testcase/ui-elements.js" ></script>
</head>
<body class="cf010">
<div id="wrap">
<div id="header">
<div id="main-header">
COOL APP
</div>
</div>
<div id="main-body">
<div id="content">
<div class="col main">
<div id="main">
<form method="post" id="testcaseForm" class="typea" action="">
<fieldset>
<legend>Test Case Builder</legend>
<div id="tk1" class="tabcontrol">
<ul class="tabs">
<li class="first active">
<a href="#">
<span>General</span>
</a>
</li>
<li class="last">
<a href="#">
<span>Parameters</span>
</a>
</li>
</ul>
<div id="tab0" class="tc-panel">
<dl class="cls9">
<dt>
<label for="scenario">Choose Scenario:</label>
</dt>
<dd>
<input type="text" id="scenario" name="scenario" class="text" />
<span id="scenarioToggle"></span>
<div class="auto-complete" id="scenarioContainer"></div>
</dd>
<dt>
<label for="ruleID">Choose Rule ID:</label>
</dt>
<dd>
<input type="text" id="ruleID" name="ruleID" class="text" />
<span id="ruleIDToggle"></span>
<div class="auto-complete" id="ruleIDContainer"></div>
</dd>
<dt>
<label for="Test Case Name" accesskey="t"><span class="accesskey">T</span>est Case Name:</label>
</dt>
<dd>
<input type="text" id="testCaseName" name="testCaseName" class="text" />
</dd>
</dl>
</div>
<div id="tab1" class="tc-panel hidden">
<div class="toolbar" id="action-bar">
<ul>
<li class="first">
<a title="select all" href="#" id="btmSelectAll" class="button">
<span>select all</span>
</a>
</li>
<li>
<a title="remove row" href="#" id="btmRemove" class="button">
<span>remove row</span>
</a>
</li>
<li>
<a title="undo last" href="#" id="btmRollBack" class="button disabled">
<span>undo last</span>
</a>
</li>
<li class="last">
<a title="accept row" href="#" id="btmAccept" class="button disabled">
<span>accept row</span>
</a>
</li>
</ul>
</div>
<div id="param.list" class="gridclip">
<table id='param.list.tbl' class='grid modela' >
<caption>Test Case Summary</caption>
<col/><col/><col/>
<thead>
<tr>
<th class='hl center first'>
<input class='grid-select-all' type='checkbox' />
<th>
<th scope='col'>Row</th>
<th scope='col'>Parameter</th>
<th scope='col' class='last'>Value</th>
</tr>
</thead>
<tfoot>
<tr>
<th scope='row'>Total</th>
<td colspan='3'>2 parameters as Test Case input</td>
</tr>
</tfoot>
<tbody id='param.list.tbl.body'>
<tr class='odd'>
<td class='rowcheck center first'>
<input value='param1###value1' id='cb1' name='SelectedRows' class='grid-select-row' type='checkbox'/>
</td>
<td class='id'>1</td>
<td>param1</td>
<td class='last'>value1</td>
</tr>
<tr class='even'>
<td class='rowcheck center first'>
<input value='param2###value2' id='cb2' name='SelectedRows' class='grid-select-row' type='checkbox'/>
</td>
<td class='id'>2</td>
<td>param2</td>
<td class='last'>value2</td>
</tr>
<tr class='odd'>
<td class='rowcheck center first' />
<td class='id'><em>new</em></td>
<td>
<dl class='clsTable'>
<dt>
<input type='text' id='param' name='param' class='text paramInput' />
</dt>
<dd>
<span id='paramToggle' />
</dd>
<div class='auto-complete' id='paramContainer' />
</dl>
</td>
<td class='last'>
<dl class='clsTable'>
<dt>
<input type='text' id='value' name='value' class='text valueInput' />
</dt>
</dl>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div> <!-- tabcontrol -->
</fieldset>
<div class="submit-box">
<input type="submit" name="formRun" id="formRun" class="form-save"
value="Execute" accesskey="x" title="Run: Press Alt + [Shift] + x" />
<input type="submit" name="formSave" id="formSave"
value="Save" accesskey="s" title="Save: Press Alt + [Shift] + s" />
<input type="submit" name="formLoad" id="formLoad"
value="Load" accesskey="l" title="Load: Press Alt + [Shift] + l" />
<input type="submit" name="formCancel" id="formCancel" class="form-cancel"
value="Cancel" accesskey="c" title="Cancel: Press Alt + [Shift] + c" />
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
As you can see the following is pretty much a duplicate:
<tr class='odd'>
<td class='rowcheck center first'>
<input value='param1###value1' id='cb1' name='SelectedRows' class='grid-select-row' type='checkbox'/>
</td>
<td class='id'>1</td>
<td>param1</td>
<td class='last'>value1</td>
</tr>
<tr class='even'>
<td class='rowcheck center first'>
<input value='param2###value2' id='cb2' name='SelectedRows' class='grid-select-row' type='checkbox'/>
</td>
<td class='id'>2</td>
<td>param2</td>
<td class='last'>value2</td>
</tr>
The relevant part of my stuts-config.xml file is:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">
<struts-config>
<data-sources />
<form-beans>
<form-bean name="TestCaseForm" type="com.blahblah.mycoolapp.forms.TestCaseForm" />
</form-beans>
<action-mappings>
<action path="/pages/SaveTestCase" name="TestCaseForm"
type="org.springframework.web.struts.DelegatingActionProxy" scope="request">
</action>
</action-mappings>
<message-resources parameter="MessageResources" />
</struts-config>
I also use spring 2.56 (The relevant part being):
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean name="/pages/SaveTestCase" class="com.blahblah.mycoolapp.actions.TestCaseBuilderSaveAction" />
</beans>
My Java ActionForm class (from what I had learned off the net) is:
package com.blahblah.mycoolapp.forms;
import java.util.ArrayList;
import java.util.List;
import org.apache.struts.action.ActionForm;
public class TestCaseForm extends ActionForm {
private static final long serialVersionUID = 2352146257739099766L;
private String scenario;
private String ruleID;
private String testCaseName;
private List<String> SelectedRows = new ArrayList<String>() ;
public String getScenario() {
return scenario;
}
public void setScenario(String scenario) {
this.scenario = scenario;
}
public String getRuleID() {
return ruleID;
}
public void setRuleID(String ruleID) {
this.ruleID = ruleID;
}
public String getTestCaseName() {
return testCaseName;
}
public void setTestCaseName(String testCaseName) {
this.testCaseName = testCaseName;
}
public List<String> getSelectedRows() {
return SelectedRows;
}
public void setSelectedRows(int index, String value) {
this.SelectedRows.add(value);
}
}
The question is why do I get an empty SelectedRows in my TestCaseBuilderSave Action?
Thanks all who have the patience to read such a long question...
and (hopefully) thanks to all you potential saviors :)
EDIT 1:
Due to #ahiru's request I post my action class which - for the time being is just a stripped down. almost do nothing, class:
public class TestCaseBuilderSaveAction extends Action {
#Override
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition","attachment;filename=superfish.xml");
try
{
ServletOutputStream out = response.getOutputStream();
String contentStr = "<Yaneeve>Has been here...</Yaneeve>";
byte[] bytes = contentStr.getBytes();
out.write(bytes, 0, bytes.length);
out.flush();
out.close();
}catch(Exception e){
e.printStackTrace();
}
return null;
}
}
I'm not a struts master or anything but can struts handle building a List out of the inputs? Would it rather be better to use an array of strings? Also have you tried adding a method in your form?
public void setSelectedRows(List<String> list) { SelectedRows = list;}
I think there is a way to define a indexed input in the struts config.
--update
Could you possibly post your action class where you are trying to get these values?
I know you said that the method above does not work but here is what works for me in a similar situation (I think). Sorry I can't find the exact code but here is what I remember:
-ActionForm
private String[] strings;
public void setStrings(String[] strings) { this.strings = strings;}
public String[] getStrings() { return strings; }
jsp/html/whatever
<input type="text" value="x" name="strings[]">
<input type="text" value="y" name="strings[]">
<input type="text" value="z" name="strings[]">
I'm also curious if spring and struts play together nicely (i've done no research on this)
It seems as if the problem had been that the checkboxes had not been 'checked'.
Only 'checked' checkboxes get their value transferred to the server...
One thing I wish to emphasize is that I had converted my code to be like what #ahiru suggested:
private String[] strings;
public void setStrings(String[] strings) { this.strings = strings;}
public String[] getStrings() { return strings; }