File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes jsp exception while using logic:iterate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "jsp exception while using logic:iterate" Watch "jsp exception while using logic:iterate" New topic
Author

jsp exception while using logic:iterate

sanju sreedharan
Ranch Hand

Joined: Nov 25, 2008
Posts: 48
hai everyone

This is my bean class named SelectionDetails.java
-------------------------------------------------

import java.util.ArrayList;
import java.io. Serializable;

public class SelectionDetails implements Serializable {
private String place_interview="";
private String date_interview="";
private String interview_schedule_userid="";

public String getPlace_interview() {
return place_interview;
}
public void setPlace_interview(String place_interview) {
this.place_interview = place_interview;
}

public String getDate_interview() {
return date_interview;
}

public void setDate_interview(String date_interview) {
this.date_interview = date_interview;
}

public String getInterview_schedule_userid() {
return interview_schedule_userid;
}
public void setInterview_schedule_userid(String interview_schedule_userid) {
this.interview_schedule_userid = interview_schedule_userid;
}
----------------------------------------------------------------------------

then i created an array list inside my actionform something like this
---------------------------------------------------------------------
private ArrayList selectionProcess=new ArrayList();

public ArrayList getSelectionProcess() {
return selectionProcess;
}

public void setSelectionProcess(ArrayList selectionProcess) {
this.selectionProcess = selectionProcess;
}
----------------------------------------------------------------------------
My action class looks like this
-------------------------------

ArrayList list=selForm.getSelectionProcess();
SelectionDetails person=new SelectionDetails();
person.setPlace_interview("");
person.setDate_interview("");
person.setInterview_schedule_userid("");
selectionProcess.add(person);
selForm.setSelectionProcess(selectionProcess);
----------------------------------------------------------------------------
this is my jsp page and this is what i want to iterate
------------------------------------------------------

<table width="100%" border=0 class="type1" cellspacing="2" cellpadding="5">
<logic:equal name="User" property="notify_dept_interview_time" value="1" >

<tr>

<td width="15%" align=right class="type1">Interview Place& Comments</td>
<td width="22%" class="type1"> <html:textarea roperty="place_interview" styleClass="textarea"/></td>

<td width="15%" align=right class="type1"> Date/Time : </td>
<td width="22%" class="type1"><html:text property="date_interview" readonly="true" styleClass="input_medium"/>

<td width="15%" align=right class="type1">Userid </td>
<td width="22%" class="type1"><html:text property="interview_schedule_userid" readonly="true" styleClass="input_medium"/></td>

</tr>
<</logic:equal>

here its fine..but when i add logic:iterate i am getting jsp exception.can anyone tell me what mistake i made.i did something like this
----------------------------------------------------------------------------

<table width="100%" border=0 class="type1" cellspacing="2" cellpadding="5">
<logic:iterate name="SelectionForm" property="selectionProcess" id="selectionProcess">

<logic:equal name="User" property="notify_dept_interview_time" value="1" >

<tr>

<td width="15%" align=right class="type1">Interview Place& Comments</td>
<td width="22%" class="type1"> <html:textarea roperty="place_interview" styleClass="textarea"/></td>

<td width="15%" align=right class="type1"> Date/Time : </td>
<td width="22%" class="type1"><html:text property="date_interview" readonly="true" styleClass="input_medium"/>

<td width="15%" align=right class="type1">Userid </td>
<td width="22%" class="type1"><html:text property="interview_schedule_userid" readonly="true" styleClass="input_medium"/></td>

</tr>
<</logic:equal>
</logic:iterate>
----------------------------------------------------------------------------
can anyone tell me my mistake and how to give iterate tag..as my deadline is approaching please help me

thanks in advance
sanju
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

It helps to state WHAT exception you're getting.

sanju sreedharan
Ranch Hand

Joined: Nov 25, 2008
Posts: 48
sorry david i forgot to tell you the exception

i am getting the exception called beanutis..when i remove index property="true" and press save its fine but again while usingindex property="true"its giving following exception..can you tell me when that exception occur.
the exception is javax.servlet.ServletException: BeanUtils.populate

thanking you
Sanju
sanju sreedharan
Ranch Hand

Joined: Nov 25, 2008
Posts: 48
david please help me else i will loose this job....can you help me please
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

http://faq.javaranch.com/java/EaseUp
http://faq.javaranch.com/java/PatienceIsAVirtue
http://faq.javaranch.com/java/DoYourOwnHomework

You're going to lose your job if I don't do your work for you? You might want to reconsider your employer if they make *my* performance a criteria for *your* position.

I don't see anything immediately obvious; it might help to post a snippet of the rendered HTML, the action code that's run on the form submit, and the configuration of the action *being submitted to*. From the limited amount of the exception trace you provide I'd guess that there's a mis-match between the form and the form of action being submitted to, but it's hard to say.

You might also try posting on the struts-user mailing list.

When posting code here please use the UBB "code" tag so it's formatted in a more-readable fashion.
sanju sreedharan
Ranch Hand

Joined: Nov 25, 2008
Posts: 48
david dont waste your time by helping me..dont do my work..i asked for help..if your reply is like this..its better you dont respond...or admit that you dont know
sanju
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

If you don't give enough information to help, then yeah, I don't know.

Good luck.
Ryan Peterson
Greenhorn

Joined: Nov 24, 2008
Posts: 5
Originally posted by sanju sreedharan:
sorry david i forgot to tell you the exception

i am getting the exception called beanutis..when i remove index property="true" and press save its fine but again while usingindex property="true"its giving following exception..


Why not remove index property="true" then if it works properly once that's done?
[ December 03, 2008: Message edited by: Ryan Peterson ]
Subrata Biswas
Greenhorn

Joined: Nov 25, 2008
Posts: 9
Hey Sanju,
in posted code snippet there is no place you are showing index property that you claimed in later reply.

Also in your action class where are you getting
selectionProcess.add(person); selectionProcess object? where as you have declared it as list.
So it should be as below -
list.add(person);
selForm.setSelectionProcess(list);

Next Can you tell me about the struts-config entry. what is the form bean name there? is it "SelectionForm" against your action mapping entry which is being used as action attributes value in your jsp form?

If all the above Question's ans is yes, then there should not be any issue as I tested with your code snippet on system. and it's working fine. Check your code properly.
sanju sreedharan
Ranch Hand

Joined: Nov 25, 2008
Posts: 48
hai subrata

thank you for the reply..is it possible to add the botton dynamically using struts...actually you can see that i have two attribte place of interview and date of interview...when i fill that and press create the same place of interview and date of interview should come again so that i can add fpr the next entry..in my case the first what i am entering is keep on repeating..any idea how to do that..

thanks sanju
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Do you mean you want to create a new button, on the current page, without submitting the form and re-rendering the entire page?
sanju sreedharan
Ranch Hand

Joined: Nov 25, 2008
Posts: 48
david

i want to know how to do it in easier way.in my existing one i can submit only one entries at a time.i want to make it for multiple entries.i want to know how to do it

thanks
sanju
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

If you want to create a new form input element (or group of elements) on the current page, without submitting the page and re-rendering the entire page, IMO the easiest way to do it is with JavaScript.

Another option is to submit an Ajax request to an action that uses JSP to create the same form elements and use the returned HTML as the contents of the DOM element holding the new form elements.
sanju sreedharan
Ranch Hand

Joined: Nov 25, 2008
Posts: 48
david what is IMO? can you tell me???
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Sorry, it means "In My Opinion".
sanju sreedharan
Ranch Hand

Joined: Nov 25, 2008
Posts: 48
david i tried to do it in javascript using innerHTML but when i tried to give struts tag inside innerHTML its giving exception..is there any other way to do it in javascript or whether i can give struts tag inside innerHTML

thanks sanju
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

You have to re-create the HTML emitted by the Struts tags.
sanju sreedharan
Ranch Hand

Joined: Nov 25, 2008
Posts: 48
yes david i did that i will sent you the code below this please tell me whats wrong in it...
this is my java script function
function addElement() {
id=id+1
var x = document.getElementById("myDiv");
var ni=x.innerHTML;
var newdiv = document.createElement('div');
newdiv.id=id;
newdiv.innerHTML=ni;
document.body.appendChild(newdiv);
this is what i want to keep on adding when i press create



<td width="22%" class="type1"/><a href="javascript:" onklick="addElement()" id="theValue">create</a>

<div id="myDiv">

<table width="100%" border=0 class="type1" cellspacing="2" cellpadding="5">

<logic:equal name="User" property="notify_dept_interview_time" value="1" >

<tr>
<td width="15%" align=right class="type1">Place_interview</td>
<td width="22%" class="type1"> <html:textarea property="place_interview" cols="40" rows="5" styleClass="textarea"/></td>

<td width="15%" align=right class="type1"> Date/Time : </td>
<td width="22%" class="type1"><html:text property="date_interview" readonly="true" styleClass="input_medium"/

<td width="15%" align=right class="type1">Userid </td>
<td width="22%" class="type1"> <html roperty="interview_schedule_userid" readonly="true" styleClass="input_medium"/></td>
</tr>

<tr>
<td colspan=3 align=middle class="type1"><a href="javascript:void()" onklick="javascript:return resumesearch()"> Candidates for Interview</a></td>
</tr>

</logic:equal>
</div>

can you please suggest me how to do it in javascript so that i can add it dynamically

thanks
sanju
sanju sreedharan
Ranch Hand

Joined: Nov 25, 2008
Posts: 48
david i will tell my whole coding so that you can check it and please tell me where i am wrong

i want to add dynamically the three attributes they are
1)date_interview,
2)place_interview
3)interview_schedule_userid

i have created a bean class named SelectionDetails.java
-------------------------------------------------------
package com.dewa.hr.edge.requisition;

import java.util.ArrayList;
import java.io. Serializable;

public class SelectionDetails implements Serializable {

private String place_interview="";
private String date_interview="";
private String interview_schedule_userid="";
public void reset(){

place_interview="";
date_interview="";
interview_schedule_userid="";
}
public String getPlace_interview()
{
return place_interview;
}
public void setPlace_interview(String place_interview)
{
this.place_interview = place_interview;
}

public String getDate_interview()
{
return date_interview;
}

public void setDate_interview(String date_interview)
{
this.date_interview = date_interview;
}

public String getInterview_schedule_userid()
{
return interview_schedule_userid;
}
public void setInterview_schedule_userid(String interview_schedule_userid) {
this.interview_schedule_userid = interview_schedule_userid;
}}
___________________________________________________________________________

this is my form class named SelectionForm.java(i created an array list to store the attribute)
--------------------------------------------------------------------------
private ArrayList selectionProcess=new ArrayList();

public ArrayList getSelectionProcess() {
return selectionProcess;
}

public void setSelectionProcess(ArrayList selectionProcess) {
this.selectionProcess = selectionProcess;
}
____________________________________________________________________________

This is my Action class i just edited and sending..in case if anyone want to see my whole action class please tell me
--------------------------------------------------------------------------

package com.dewa.hr.edge.requisition;
public class SelectionAction extends Action {
ArrayList selectionProcess=new ArrayList();
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
{
String target = F_SUCCESS;

if ( form != null )
{
try{
SelectionForm selForm = (SelectionForm)form;
String id=request.getParameter("id");
String submit=request.getParameter("submit_button");
--------------------------------------------------
selectionProcess=selForm.getSelectionProcess();
SelectionDetails sd=new SelectionDetails();
sd.setPlace_interview("");
sd.setDate_interview("");
sd.setInterview_comments_userid("");
selectionProcess.add(sd);
-------------------------------------------------
if((submit!=null&&submit.equalsIgnoreCase("Approve"){langs=new ArrayList();
grades=new ArrayList();
ageranges=new ArrayList();
nationality=new ArrayList();
selForm=this.approve(selForm,request,user);
}else

if(alert!=null&&alert.equalsIgnoreCase("yes")){
langs=new ArrayList();
grades=new ArrayList();
ageranges=new ArrayList();
nationality=new ArrayList();
target="alert";
}else
{
langs=new ArrayList();
grades=new ArrayList();
ageranges=new ArrayList();
nationality=new ArrayList();
langs=dmlu.getAllLanguages();
grades=dmlu.getAllGrades();
ageranges=dmlu.getAllAgerange();
nationality=dmlu.getAllNationality();
}
request.setAttribute("selectionProcess",selectionProcess);
}catch(Exception e){
e.printStackTrace();
}
}
return mapping.findForward(target);
}
____________________________________________________________________________

This is my jsp page.
---------------------------------------------------------------------------

<table width="100%" border=0 class="type1" cellspacing="2" cellpadding="5">
<td width="22%" class="type1"/><a href="javascript:" onklick="addElement()" id="theValue">create</a>

<div id="myDiv">

<table width="100%" border=0 class="type1" cellspacing="2" cellpadding="5">
<logic:iterate id="selectionProcess" name="selectionProcess" indexId="elementIndex">

<logic:equal name="User" property="notify_dept_interview_time" value="1" >

<tr>
<td width="15%" align=right class="type1">Place_interview</td>
<td width="22%" class="type1"> <html:textarea indexed="true" property="place_interview" name="selectionProcess"

<td width="15%" align=right class="type1"> Date/Time : </td>
<td width="22%" class="type1"><html:text indexed="true" property="date_interview" name="selectionProcess" styleClass="input_medium"/>

<td width="15%" align=right class="type1">Userid </td>
<td width="22%" class="type1"> <html:text indexed="true" property="interview_schedule_userid" name="selectionProcess" readonly="true" styleClass="input_medium"/></td>
</tr>
</logic:equal>
</logic:iterate>
</table>
</div>
____________________________________________________________________________
someone please tell me i am really stuck over here.

thanks in advance
sanju
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Please use the UBB "code" tags when posting code; it's much easier to read.

If you're using an indexed property, the JavaScript for creating the new form elements must also create an incremented index: right now the JavaScript is just copying everything from DIV#myDiv into the new DIV.

It also appears that DIV#myDiv contains *all* of the elements since it contains the <logic:iterate...> tag, so you'll get duplicates of each row of input elements--probably not what you want.

You're also appending the copied HTML to the document body, which is almost certainly not what you want--it needs to go inside the table containing the other form elements.

These, however, are all JavaScript, DOM, and HTML issues, not Struts.

I'd suggest first getting it working without the incorrect JavaScript to isolate the BeanUtils exception.

Also, this chunk of code has redundancies--you're creating new ArrayLists unnecessarily:



Lastly, if those array lists (langs, grades, etc.) are instance properties (i.e., members of the action, not local variables in a method) this is probably bad: actions are not created per-request--like servlets there is only one instance of an action serving any request, unless you have modified (or extended) Struts, the request processor, etc. As soon as there are multiple users hitting the same action you will see non-deterministic data-oriented errors.
[ December 15, 2008: Message edited by: David Newton ]
sanju sreedharan
Ranch Hand

Joined: Nov 25, 2008
Posts: 48
can you tell me with the help of code how to do it?because i am not getting idea how to do it???

thanks sanju
sanju sreedharan
Ranch Hand

Joined: Nov 25, 2008
Posts: 48
thanks david

Atlast i solved it last week..this site is very useful.the author of the site is really appreciated

sanju
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jsp exception while using logic:iterate