• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jsp

 
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<%
String comment2 ="";
String apptype ="";

String diffMonth = "";
int diffMonths = 0;
ArrayList appDetails = new ArrayList();
Hashtable htAppDet = new Hashtable();
Hashtable htAppDet1 = new Hashtable();
Hashtable htAppDet2= new Hashtable();
ExcedBean Bean = new ExceedApprovalBean();


diffMonth = (String) request.getAttribute("MONTHDIFF");
diffMonths = Integer.parseInt(diffMonth);


Integer[] months = new Integer[diffMonths];
Integer[] years = new Integer[diffMonths];


String[] monthNames = {"January","February","March","April","May","June","July","August","September","October","November","December"};
Calendar cal = Calendar.getInstance();
cal.setTime(cal.getTime());
months[0] = Integer.valueOf(""+(cal.get(cal.MONTH)+1));
years[0] = Integer.valueOf(""+cal.get(cal.YEAR));

for(int i=1;i<diffMonths;i++){
cal.add(cal.MONTH,-1);
String monthVal = ""+(cal.get(cal.MONTH)+1);
String yearVal = ""+cal.get(cal.YEAR);
months[i] = Integer.valueOf(monthVal);
years[i] = Integer.valueOf(yearVal);
}

ArrayList appDet = new ArrayList();
appDet = (ArrayList) request.getAttribute("APPDET");


for(int j=0;j<appDet.size();j++){

Bean = (ExcedBean) appDet.get(j);

htAppDet.put((String)Bean.getMonth()+(String)Bean.getYear(),(String)Bean.getType());
htAppDet1.put((String)Bean.getMonth()+(String)Bean.getYear(), (String)Bean.getReason());
htAppDet2.put((String)Bean.getMonth()+(String)Bean.getYear(), (String)Bean.getComments());


}




%>




function setDefaultAStatus(type,val){
for (i=0;i<<%=months.length%>;i++) {
var selObj = document.getElementById(type+""+i);
var length = selObj.length;
for (j=0;j<length;j++) {
if (selObj.options[j].text == val){
selObj.selectedIndex = j;
}
}
}
}

function setDefaultAReason(type,val){
for (i=0;i<<%=months.length%>;i++) {
var selObj = document.getElementById(type+""+i);
var length = selObj.length;

for (j=0;j<length;j++) {
if (selObj.options[j].text == val){
selObj.selectedIndex = j;
}
}
}
}

function setActualAReason(type){
vals = (document.all("nMonApps")).value;
if (vals!=null&&vals!=""){
for (j=0;j<vals;j++){
var apReasonObj = document.getElementById("aReason"+(j));
var monYearObj = document.all("monYear"+(j));
if (monYearObj){
for (i=0;i<<%=months.length%>;i++) {
var selObj = document.getElementById(type+""+i);
var length = selObj.length;
var monYearValue = monYearObj.value;

var monYear = (document.all("mon"+(i))).value+(document.all("yr"+(i))).value;


if (monYear==monYearValue){
for (k=0;k<length;k++) {
var aReason = aReasonObj.value;
if (selObj.options[k].text == aReason){
selObj.selectedIndex = k;
}
}
}
}
}
}
}
}


function setActualAStatus(type){
vals = (document.all("nMonApps")).value;
if (vals!=null&&vals!=""){
for (j=0;j<vals;j++){
var appObj = document.all("aType"+(j));

var monYearObj = document.all("monYear"+(j));
if (monYearObj){
for (i=0;i<<%=months.length%>;i++) {
var selObj = document.getElementById(type+""+i);


var length = selObj.length;
var monYearValue = monYearObj.value;
var monYear = (document.all("mon"+(i))).value+(document.all("yr"+(i))).value;

if (monYear==monYearValue){
for (k=0;k<length;k++) {
var aType = appObj.value;

if (selObj.options[k].text == aType){
selObj.selectedIndex = k;
}
}
}
}
}
}
}
}




</script>
</HEAD>
<table>
<tr>
<td>      </td>
<td>      </td>
<td>      </td>
<td>      </td>
<td>      </td>
<td>      </td>
<td>
<table width="560" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" height="25" class="gridHeader">Month</td>
<td style="padding-left=7px" align="left" height="25" class="gridHeader">Year</td>
<td align="left" height="25" class="gridHeader">AStatus</td>
<td align="left" height="25" class="gridHeader">AReason</td>
<td align="left" height="25" class="gridHeader">Comments</td>
</tr>
</table>
<div style="overflow:auto;width:560px; height:250px; ">
<table width="430" border="1" cellspacing="0" cellpadding="0">

<%
int len = months.length;

for (int i = (len-1); i >= 0; i--) {
%>


<tr <%if ((i+1) % 2 == 0) {%>class="gridRowAlt"<%} else {%>class="gridRow"<%}%>>
<td style="padding-left=3px" class="formField"><%=monthNames[months[i].intValue()-1]%></td>
<input type="hidden" name="smonth<%=i%>" value="<%=monthNames[months[i].intValue()-1]%>">
<td class="formField" align="center"><%=years[i]%></td>
<input type="hidden" name="syear<%=i%>" value="<%=years[i]%>">
<input type="hidden" name="syrmon<%=i%>" value="<%=years[i]+monthNames[months[i].intValue()-1]%>">
<td class="formField" align="left"><select size="1" name="aStatus<%=i%>" class="formList">
<script>
document.write(top.buildDropdownList("VALS"));
</script>
</td>
<td class="formField" align="left"><select size="1" name="aReason<%=i%>" class="formList">
<script>
document.write(top.buildDropdownList("REASON"));
</script>

</td>
<td class="formField" align ="center"><input type="text" name="comments<%=i%>" value="<%=Bean.getComments()%>"></td>
</tr>
<%}%>

</table>
</div>
</td>
</tr>

</table>
<%
Enumeration keys = htAppDet.keys();
Enumeration keys1 = htAppDet1.keys();

String monthYear = "";
String monthYear1 = "";
String monthYear2 = "";
String apprType = "";
String apprReason = "";
String comments ="";
int nMon = 0;

while ((keys.hasMoreElements())&& (keys1.hasMoreElements())) {

monthYear = (String) keys.nextElement();
monthYear1 = (String) keys1.nextElement();
aType = (String) htAppDetails.get(monthYear);
aReason =(String) htAppDetails1.get(monthYear1);
String mon = monthYear.substring(0,2);
%>
<input type="hidden" name="monYear<%=nMon%>" value="<%=monthYear%>">
<input type="hidden" name="appType<%=nMon%>" value="<%=aType%>">
<input type="hidden" name="appReason<%=nMon%>" value="<%=aReason%>">
<%-- <input type ="hidden" name ="comments<%=nMon%>" value="<%=comments%>">--%>
<%
nMon++;
}%>

<form name="dummyForm" method="post"></form>
</BODY>
</HTML>

In the last
Could please tell me, how to access "COMMENTS" in this code. I am getting null value when I say "Bean.getcomments()".
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Javaranch Tip:

If you're going to post more than a line or two of your code, wrap them in UBB CODE tags. There is a CODE button on the edit screen to generate them for you. Doing so will preserve your indenting which will make your code much easier to read.

The easier it is to read, the more people will read it.
The more they read it, the more likely they are to help.

PS: You can add them after the fact, too.
 
phani kon
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[Bear edit: remvoed re-post of the same block of unformatted code as the initial post. "lak kal" if you are going to re-post the code, please use the UBB code tags as Ben suggested.]
[ September 29, 2005: Message edited by: Bear Bibeault ]
 
phani kon
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know how to use UBB code
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you surround your code like this:

[code]
System.out.println("Hey there");
[/code]

and it looks like this:



Dave
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Or use the button labeled CODE under the text entry area. It will insertt he tags for you.
 
phani kon
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<td class="formField" align ="center"><input type="text" name="comments<%=i%>" value="<%=Bean.getComments()%>"></td>
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Regarding Bean.getComments() you may be using the wrong object type.

You are treating your ExceedApprovalBean like a ExcedBean, which may be hiding the method.

By the way: in Java we prefer varables to start with a lower case character 'bean', not 'Bean'.

Dave
 
phani kon
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't see the previous code? See the latest code it is ExcedBean only?

My question is how can I access Comments. Because I am getting null values If I say bean.getComments(). It is in the arraylist of appDet.
 
Why does your bag say "bombs"? The reason I ask is that my bag says "tiny ads" and it has stuff like this:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic