Sunitha Arun

Greenhorn
+ Follow
since Dec 28, 2011
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Sunitha Arun


hi all,
i want to write a junit test case for testing a database query function.
I am getting the following error:

Cannot get connection: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial

The following is my code



Please help me to solve this issue.


Regards,
Sunithamm
Hi all,
I am having a datetimepicker which works fine. I want to customize it such as changing background color, increase text font size etc.
Is there any way for doing this?

Regards,
Sunitha.
12 years ago
Hi all,
We are having a list containg checkbox in each row.Each row contains a link for an action(not the submit button). We need to get selected check box value in that action.

Thanks and regards,
Sunitha.
12 years ago
Hi all,
i am having a jsp containing two select boxes..second select box is populated depending upon the value of the first select box using ajax. it is working fine.
Now i want to preselect values in both select boxes when the page loads.. how can i do this? i am able to select the value of first select box.
12 years ago
Hi all,
Can you please tell me how we can handle cookies in struts2?
12 years ago
Hi all,
i am having a jsp page with an <s:select>.
<s:select> is populated from db. when i press a key, for example 's' in keyboard, i want the first item starting with letter 's' to be selected in <s:select>

Can you please suggest a solution

Regards,
Sunitha
12 years ago
Hi

Thank you so much for your reply..

I tried with what you said.. but it didn't work

I modified trucklist.jsp as follows:

<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
<script type="text/javascript">
function getSelectedValue() {

var e = document.getElementById("sel_truck");
var strUser = e.options[e.selectedIndex].value;

document.getElementById("hiddenSelectedValue").value = strUser;

}
</script>
</head>
<body>
<s:form>
<s:select list="truckList" headerKey="1" name="sel_truck"
id="sel_truck" onchange="getSelectedValue()"></s:select>
<input type="hidden" id="hiddenSelectedValue"
name="formHiddenFieldValue" />

</s:form>
</body>
</html>

It didnt give me the expected result. Please let me know if i did it in the correct way.

Thanks and Regards,
Sunitha
12 years ago
Hi all,
I am having two select boxes in my jsp page. I need to populate second select box depending upon the value selected in first select box. I am able to do this. But the problem is i am not getting the value selected in the second select box in the action class. i have provided getters and setters for both select boxes.

The code snippets are given below

index.jsp
----------

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<s:head theme="ajax" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script type="text/javascript">
function show_details() {
dojo.event.topic.publish("populate");
}
</script>
</head>
<body>
<s:form id="innerForm" name="innerForm">
<table>
<tr>
<td>TRANSPORTER:</td>
<td><s:select list="{'APPOLO','RAJENDRA','SUMAN'}"
headerKey="0" headerValue="-Please Select-"
onchange="show_details()" id="sel_transporter"
name="sel_transporter">
</s:select></td>
</tr>
<tr>
<td>TRUCK:</td>
<s:url action="populateTruckAction" id="truck_url" />
<td><s:div href="%{truck_url}" listenTopics="populate"
formId="innerForm" theme="ajax" id="truckDiv"></s:div>
</td>
</tr>
<tr>
<td>Submit:</td>
<td><a id="print_anchor" href="<s:url action='printAction'/>">PRINT
</a></td>
</tr>
</table>
</s:form>
</body>
</html>


trucklist.jsp
------------


<%@ taglib prefix="s" uri="/struts-tags"%>
<s:select list="truckList" headerKey="1" name="sel_truck" id="sel_truck"></s:select>

result.jsp
-----------

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<s:form name="form1">
Transporter:<s:property value="sel_transporter"/>
Truck:<s:property value="sel_truck"/>
</s:form>
</body>
</html>

struts.xml
-----------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="false" />
<package name="" extends="struts-default">
<action name="populateTruckAction" class="com.sample.MainAction"
method="populateTruck">
<result name="input">/index.jsp</result>
<result name="success">/trucklist.jsp</result>
</action>
<action name="printAction" class="com.sample.MainAction"
method="print">
<result name="success">/result.jsp</result>
</action>
</package>
</struts>


MainAction.java
-----------------

package com.sample;

import java.util.LinkedList;

import com.opensymphony.xwork2.ActionSupport;

public class MainAction extends ActionSupport {
private static String sel_transporter;
private static String sel_truck;
private LinkedList<String> transList = new LinkedList<String>();
private LinkedList<String> truckList = new LinkedList<String>();

public String populateTruck() {
System.out.println("inside populate Truck...." + sel_transporter);
if (sel_transporter.equals("APPOLO")) {
truckList.add("APP01");
truckList.add("APP02");
} else if (sel_transporter.equals("RAJENDRA")) {
truckList.add("RAJ01");
truckList.add("RAJ02");
} else {
truckList.add("SUM01");
truckList.add("SUM02");
}
return SUCCESS;
}

public String print() {
System.out.println(getSel_transporter()+"---"+getSel_truck());
return SUCCESS;
}

public String getSel_transporter() {
return sel_transporter;
}

public void setSel_transporter(String sel_transporter) {
MainAction.sel_transporter = sel_transporter;
}

public String getSel_truck() {
return sel_truck;
}

public void setSel_truck(String sel_truck) {
MainAction.sel_truck = sel_truck;
}

public LinkedList<String> getTransList() {
return transList;
}

public void setTransList(LinkedList<String> transList) {
this.transList = transList;
}

public LinkedList<String> getTruckList() {
return truckList;
}

public void setTruckList(LinkedList<String> truckList) {
this.truckList = truckList;
}
}


Looking forward to hear from you....

Regards,
Sunitha
12 years ago