I am loading a map of values into ServletContext during start of the application/server
HashMap<String, List<String>> cfsUfsMap = new HashMap<String, List<String>>();
//some operations
application.setAttribute("UDM_UFS_CFS_MAP", cfsUfsMap); //application = ServletContext
I need to use this map directly in JSP page, for which I have done this
<s:set name="udm_cfs_ufs_map" value="#application.UDM_UFS_CFS_MAP" />
<table class="first" width="100%" border="0" cellpadding="0" id="sups_assignedservices_info_table">
<tr>
<th width="30%">Assigned service name </th>
<th width="15%">CFS Code </th>
<th width="15%">Status </th>
<th width="20%">Date </th>
<th width="20%">UDM </th>
</tr>
<s:iterator value="#sups_services.services">
<s:set name="ufs_list" value="#udm_cfs_ufs_map.['top.code']" />
<tr>
<td class="light"><s:property value="top.name"/> </td>
<td class="light"><s:property value="top.code"/> </td>
<td class="light"><s:property value="top.status"/> </td>
<td class="light"><s:property value="top.date"/> </td>
<td class="light"><s:property value="#udm_cfs_ufs_map.size()" /> - <s:property value="#ufs_list.size()" /></td>
</tr>
</s:iterator>
As you see, I am trying to get the values (List) from map using key which's top.code
However I am getting original map size but not the list size based on key.
Any idea what's missing/going wrong
Done.
I solved it myself. I am posting my mistakes and the correct solution. SO down the line it might be useful to someone
to access servletContext attributes
<s:set name="udm_cfs_ufs_map" value="#application.UDM_UFS_CFS_MAP" />
for fetching the content from the map based on key
<s:iterator value="#sups_services.services">
<s:set name="ufs_list" value="#udm_cfs_ufs_map[top.code]" />
<tr>
<td class="light"><s:property value="top.name" /></td>
<td class="light"><s:property value="top.code" /></td>
<td class="light"><s:property value="top.status" />
</td>
<td class="light"><s:property value="top.date" /></td>
<td class="light"><s:iterator value="ufs_list">
<s:property />
<br />
</s:iterator></td>
</tr>
Related
I have the next HTML Datatable
<div class="tabla-jquery">
<table id="comparativa-data-table" class="dataTable" cellpadding="0" cellspacing="0" border="0">
<thead>
<tr>
<th>Titulo</th>
<th colspan="3">Fecha</th>
</tr>
</thead>
<tbody>
<tr>
<td>Prueba</td>
<td>Izda</td>
<td>Drha</td>
<td>Axial</td>
</tr>
</tbody>
</table>
</div>
And when I see the table, I get this error: Cannot read property 'fnSetData' of undefined
But when I change the HTML and put this:
<div class="tabla-jquery">
<table id="comparativa-data-table" class="dataTable" cellpadding="0" cellspacing="0" border="0">
<thead>
<tr>
<th>Titulo</th>
<th>Fecha</th><th>Fecha</th><th>Fecha</th>
</tr>
</thead>
<tbody>
<tr>
<td>Prueba</td>
<td>Izda</td>
<td>Drha</td>
<td>Axial</td>
</tr>
</tbody>
</table>
</div>
It works "fine"(I only want a Fecha header instead of 3):
Anyone knows why occur this?
Thanks for your time!
Try like this :
<div class="tabla-jquery">
<table id="comparativa-data-table" class="dataTable" cellpadding="0" cellspacing="0" border="0">
<thead>
<tr>
<th>Titulo</th>
<th colspan="3">Fecha</th>
<th style="display:none;">Fecha</th>
<th style="display:none;">Fecha</th>
</tr>
</thead>
<tbody>
<tr>
<td>Prueba</td>
<td>Izda</td>
<td>Drha</td>
<td>Axial</td>
</tr>
</tbody>
</table>
<table class="table hover" id="resultTable">
<thead>
<tr>
<th rowspan="1" class="checkbox-col"><input type="checkbox" id="ohrmList_chkSelectAll" name="chkSelectAll" value=""></th>
<th rowspan="1" style="width:400" class="header">Report Name</th>
<th rowspan="1" style="width:95"><span class="headerCell"></span></th>
<th rowspan="1" style="width:95"><span class="headerCell"></span></th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><input type="checkbox" id="ohrmList_chkSelectRecord_5" name="chkSelectRow[]" value="5"></td> <td class="left">PIM Sample Report</td>
<td class="left">Run</td>
<td class="left">Edit</td>
</tr>
<tr class="even">
<td><input type="checkbox" id="ohrmList_chkSelectRecord_6" name="chkSelectRow[]" value="6"></td> <td class="left">Sample Report</td>
<td class="left">Run</td>
<td class="left">Edit</td>
</tr>
</tbody>
</table>
I'm a beginner to selenium, so I need a help to click a link (Run)of a Record from multiple Records in the table contains multiple Rows of different class with same class name for each column. I have attached the code snippet.
I tried this Xpath but is not working:
//table[#class='table hover']/tbody/tr/td[text()='PIM Sample Report'] and ./td[text()='Run']
can someone help me to figure out this?
Try to use below XPath :
//td[.="PIM Sample Report"]/following-sibling::td[.="Run"]/a
This should fetch the link "Run" preceded by td with text "PIM Sample Report"
I'm newbish on Struts2 and can't find the answer to the following question online.
Here's the process I'm currently trying to create.
First the user sends an user ID or a contract ID, and I fetch informations in my Oracle database. These informations are then showed to the user in the form of a list. Within each row, it's possible to modify one information via a radio button. The radio's value is preselected to the corresponding fetch'd value. The radio's name is a concatenation of the differents primary keys of my table (3).
No problem so far. The struggle starts now. I want to get for each row the value of the radio's name and the selected value. I found solutions for that but you need getters on the radio's name hard coded in the Java bean.
Can anyone help ?
Here is the Struts 2 form :
<s:form id="updateform" theme="simple" action="UpdateInterlocuteurADP">
<table>
<thead>
<tr>
<th scope="col"><s:text name="parametrage_recherche_interlocuteur_adp_form_devis" /></th>
<th scope="col"><s:text name="parametrage_liste_interlocuteur_adp_col_interlocuteur" /></th>
<th scope="col"><s:text name="parametrage_liste_interlocuteur_adp_col_type_alerte" /></th>
<th scope="col"><s:text name="parametrage_liste_interlocuteur_adp_col_canal" /></th>
<th scope="col"><s:text name="parametrage_liste_interlocuteur_adp_col_mobile" /></th>
<th scope="col"><s:text name="parametrage_liste_interlocuteur_adp_col_email" /></th>
</tr>
</thead>
<tbody>
<input type="hidden" name='resultSearch' value="resultatInterlocuteurADP.list">
<s:iterator value="resultatInterlocuteurADP.list" status="resStatus">
<tr class="result-list-row-even">
<td align="center"><s:property value="idDevis"/></td>
<td align="center"><s:property value="interlocuteur"/></td>
<td align="center">
<s:if test="%{'SC_ALER_DERI'.equals(typeService)}">Dérive</s:if>
<s:if test="%{'SC_ALER_DEPA'.equals(typeService)}">Dépassement</s:if>
<td align="center">
<s:radio list="canaux" value="canal" name="%{cleConcat}"/>
</td>
<td align="center"><s:property value="numeroMobile"/></td>
<td align="center"><s:property value="adresseEmail"/></td>
</tr>
</s:iterator>
</tbody>
</table>
</br>
<s:submit onClick="return updateButtonPressed()" theme="simple" id="ok"
value="%{getText('parametrage_liste_interlocuteur_adp_button_submit')}" />
Im stucked in java based selenium usage, i like to click on input box (within table )by another cell text value
Here is my HTML code:
<DIV class=>
<P class=></P>
<UL></UL>
<FORM id="" onsubmit="" method=post name="" action="">
<TABLE width="100%">
<TBODY>
<TR>
<TD class=></TD></TR></TBODY></TABLE>
<TABLE>
<TBODY>
<TR>
<TD class=></TD></TR>
<TR>
<TD>
<TABLE class="" width="70%">
<TBODY>
<TR class="">
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD></TR>
<TR class="">
<TD><INPUT class="" onclick="" CHECKED type=checkbox><INPUT id= value=true type=hidden name=""> </TD>
<TD></TD>
<TD></TD>
<TD></TD></TR></TBODY></TABLE></TD>
<TR>
<TD><INPUT id="" class= onclick='' value="" type=button name=></TD></TR></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=""></TD></TR>
<TR>
<TD>
<TABLE class=foo width="100%">
<TBODY>
<TR class=foo-header>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD></TR>
<TR class="foo-odd">
<TD><INPUT onclick="" value="0" type="radio" name=""> </TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD></TR>
<TR class="foo-even">
<TD rowSpan="3"><INPUT onclick="" value="1" CHECKED type="radio" name=""> </TD>
<TD rowSpan="3"></TD>
<TD rowSpan="3"></TD>
<TD rowSpan="3"></TD>
<TD rowSpan="3"></TD>
<TD rowSpan="3"></TD>
<TD rowSpan="3"></TD>
<TD></TD>
<TD rowSpan="3"><INPUT id="" class="" value="" type="" name=""></TD></TR>
<TR class="foo-even">
<TD></TD></TR>
<TR class="foo">
<TD>CCC</TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD><INPUT class="" onclick="" type=checkbox><INPUT id="" value="false" type="hidden" name=""> </TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=""></TD></TR>
<TR>
<TD>
<TABLE class="foo" width="100%">
<TBODY>
<TR class="foo-header">
<TD></TD>
<TD><BR><INPUT id="" class="" onclick="" value="" type="button" name=""></TD>
<TD colSpan="3"></TD>
<TD></TD></TR>
<TR class="foo-odd">
<TD><INPUT value="0" type="radio" name=""> </TD>
<TD></TD>
<TD></TD>
<TD colSpan="2"></TD>
<TD><SELECT class="" name=""> <OPTION value="0"></OPTION> <OPTION selected value="1"></OPTION></SELECT> </TD></TR>
<TR class="foo-even">
<TD rowSpan="2"><INPUT value="1" type="radio" name=""> </TD>
<TD rowSpan="2"></TD>
<TD rowSpan="2"></TD>
<TD></TD>
<TD></TD>
<TD rowSpan="2"><SELECT class="" name=""> <OPTION value="0"></OPTION> <OPTION selected value="1"></OPTION></SELECT> </TD></TR>
<TR class="foo">
<TD>CCC</TD>
<TD></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
</DIV>
I like to click on the second CCC text row related input,(not by only clicking name or xpath) im tried with followings:
driver.findElement(By.xpath(".//td[contains(text(),'CCC')]/preceding-sibling::td")).click();
Code above working in a *very similar html only contains CCC one time (tested with another HTML code )
WebElement services = driver.findElement(By.xpath(".//*[#id='installationAddressForm']/table[4]/tbody/tr[2]/td/table/tbody/tr[4]/td[1][contains(text(),'CCC')]"));
String contents = services.getText();
System.out.println(contents);
Code above able to find text but when combined with the top code(/preceding-sibling::td) it cannot find the input
Please help.Thanks in advance
The expression td[1][contains(text(),'CCC')] selects the first td and tests whether its text contains CCC.
Replace it with td[contains(text(),'CCC')][1].
I'd like to know if there's any way to send data to the server for the selected rows using the checkboxes I've put on those rows? I mean , how can I send only the data of those selected rows to the server?
Here's the html code I use:
<table>
<thead>
<tr class="tableheader">
<td width="10%"></td>
<td width="30%">Vehicle</td>
<td width="40%">Driver</td>
<td width="10%">Mileage</td>
</tr>
</thead>
<tbody>
<c:forEach items="${list}" var="item">
<tr>
<td align="center">
<input type="checkbox" name="selectedItems"
value="c:out value="${item.numberPlate}"/>"/>
</td>
<td align="left"><c:out value="${item.numberPlate}"/></td>
<td align="left"><c:out value="${item.driver.fullName}" /></td>
<td align="left"><input type="text" name="mileage" value="" /></td>
</tr>
</c:forEach>
</tbody>
</table>
I really hope you can give some guidance on this.
Thanks in beforehand.
When handling the request use request.getParameterValues("selectedItems"). And I don't think it's needed to add [] to names