• 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

creating html form dynamically using logic:iterate

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello
I am new to Struts. I have retrieved data dynamically in form of list in action class.Now I want to write each row in different html form with two submit buttons on each form on the same page. i.e I want to create dynamic <html:form> with dynamic <html:submit> on it with a row of data retrieved dynamically. Please someone help me out.

Thanks in advance
Regards Ann
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Ann, I strange to here about your post, tell me one thing wha is the neccessity to create dynamic forms with dynamic submit(), actually as for the struts we have seperate form for each jsp page, and by default we use that forname everywhere in that whole html.

anyways try with this code it may help you

<logic:iterate name="formBeanName" type="package root of formBeanName" property="args" id="id" indexId="indId">
<html:form action="/actionName">
// enter the required code here
</html:form>
</logic:iterate>

each form will have a seperate formName and submit

Cheers/
Suman
 
Ann Anderson
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Suman

I have tried the same code you have written below but my page was not displayed when I added the line
<html:form action="/actionName"> so I felt I was wrong somewhere. I will try again.
Below is the code.

I am using struts1.3.10

**********************************
This is my Action class
**********************************
public class ViewCelebrity extends Action {

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)throws Exception{
List listLoginData = new ArrayList();
SessionFactory sessionFactory;
Session session;
Transaction transaction;
Configuration configuration;
Query query;

try {
LoginForm loginForm = new LoginForm();
sessionFactory=new Configuration().configure().buildSessionFactory();
session=sessionFactory.openSession();
transaction=session.beginTransaction();
query = session.createQuery("from LoginForm loginData");
listLoginData = query.list();
request.setAttribute("listLoginData", listLoginData);
}
catch(Exception e){
e.printStackTrace();
}

return mapping.findForward("success");
}//end of execute
}



****************************************
This is my ActionForm calss
****************************************

public class LoginForm extends ValidatorForm{

private String userName;
private String passWord;
private String pin;
private String reType;

public void setUserName(String userName){
this.userName = userName;
System.out.println("Inside setUserName");
}

public void setPassWord(String passWord){
this.passWord = passWord;
System.out.println("Inside setPassWord");
}

public void setPin(String pin){
this.pin = pin;
System.out.println("Inside setPin");
}

public void setReType(String reType){
this.reType = reType;
System.out.println("Inside setReType");
}

public String getUserName(){
System.out.println("Inside getUserName");
return userName;
}

public String getPassWord(){
System.out.println("Inside getPassWord");
return passWord;
}

public String getPin(){
System.out.println("Inside getPin");
return pin;
}

public String getReType(){
System.out.println("Inside getReType");
return reType;
}

public void reset(){

}
}


*******************************************
This is my .jsp page
*******************************************

<tiles:insert attribute="header"/>
<table bgcolor="green" width="100%">
<tr>
<td>User Name</td>
<td>Password</td>
<td>Pin</td>
</tr>
<logic:iterate id="cele" name="listLoginData">
<tr>
<html:form action="/action">
<td><bean:write name="cele" property="userName" /></td>
<td><bean:write name="cele" property="passWord"/></td>
<td><bean:write name="cele" property="pin"/></td>
</html:form>
</tr>
</logic:iterate>
</table>
<tiles:insert attribute="footer"/>

_______________________________________________________________________


I have one more question. I want each row to be placed on different tile and insert the tiles on this page dynamically. How should i do?

Regards
Ann
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic