Re: logic:iterate tag!

2007-03-10 Thread Laurie Harper
OK, so you have an object in session scope under the key 'AFFFiles', 
which is an ArrayList containing FileObj instances. Did you mean to fill 
it with the FileReceiptFormBean instances instead maybe? If not, what 
properties does a FileObj have?


L.

Swaminathan Subramanian wrote:

Hi Laurie!
Thanks for the prompt response. I am pasting code snippets at every level 
(ActionForm, Action class and view). This did not work. Please let me know if I 
am missing something here.
Thanks again!


//*ActionForm class
//core java classes
import java.util.ArrayList;
import java.util.Collection;

// Java extension classes
import javax.servlet.http.HttpServletRequest;
// third-party classes
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
// local project classes
import com.foo.foo1.web.Constants;
import com.foo.foo1.soapcalls.FileObj;
public final class FileReceiptFormBean extends ActionForm
{
 
 // File specific property variables
 
 private String  fileName;

 private String  fileType;
 private String  fileSize;
 private String  fileModifiedDate;
 private String  multipleFiles;
 private String  fileURL;
 private ArrayList alObjFile;
 private FileObj objFile;

 public String  getFileName()

 {
   return (this.fileName);
  }
  public void setFileName(String fileName)
  {
   this.fileName = fileName;
 }
 public String  getfileType()
  {
   return (this.fileType);
  }
  public void setfileType(String fileType)
  {
   this.fileType = fileType;
 }
 public String  getfileSize()
  {
   return (this.fileSize);
  }
  public void setfileSize(String fileSize)
  {
   this.fileSize = fileSize;
 }
  public String  getfileModifiedDate()
  {
   return (this.fileModifiedDate);
  }
  public void setfileModifiedDate(String fileModifiedDate)
  {
   this.fileModifiedDate = fileModifiedDate;
 }
  public String  getmultipleFiles()
  {
   return (this.multipleFiles);
  }
  public void setmultipleFiles(String multipleFiles)
  {
   this.multipleFiles = multipleFiles;
 }
  public String  getfileURL()
  {
   return (this.fileURL);
  }
  public void setfileURL(String fileURL)
  {
   this.fileURL = fileURL;
 }
  public ArrayList  getAlObjFile()
  {
   return (this.alObjFile);
  }
  public void setAlObjFile(ArrayList alObjFile)
  {
   this.alObjFile = alObjFile;
 }
 public FileObj  getObjFile()
  {
   return (this.objFile);
  }
  public void setObjFile(FileObj FileObj)
  {
   this.objFile = objFile;
 }   
   
}


//*End ActionForm class

//*Action class

ArrayList alAFFFile = new ArrayList();
FileObj[] objFiles = null;
objFiles = intf.getFiles(ctx, filename);
String affUrl = ;
for ( int i=0; i  objAFFFiles.length; i++)
{
 affUrl = objFiles[i].fileURL;
 FileReceiptFormBean frfBean = new FileReceiptFormBean();
 frfBean.setFileName(objFiles[i].fileName);
 frfBean.setfileType(objFiles[i].fileType);
 frfBean.setfileSize(objFiles[i].fileSize);
 frfBean.setfileModifiedDate(objFiles[i].fileModifiedDate);
 frfBean.setmultipleFiles(objFiles[i].multipleFiles);
 objFiles[i].fileURL = LoadFileUrlCreator.create(affUrl, application/zip, 
true);
 frfBean.setfileURL(objAFFFiles[i].fileURL);   
 alFile.add(objAFFFiles[i]);

}
session.setAttribute(AFFFiles, alAFFFile);
//*End Action class
//*view.jsp
logic:iterate id=afffiles name=AFFFiles 
 bean:write name=afffiles property=fileName/
/logic:iterate

- Original Message 
From: Laurie Harper [EMAIL PROTECTED]
To: user@struts.apache.org
Sent: Thursday, March 8, 2007 5:11:20 PM
Subject: Re: logic:iterate tag!


Swaminathan Subramanian wrote:

All,
I am working on application using Struts 1.0. I am trying to display an 
ArrayList of complex objects using the logic:iterate tag..
Here's some more details - 


FileObj
 fileName
 fileSize
 fileType
 fileModifiedDate

Action class
FileObj[] objFiles = null;
objFiles = intf.getFiles(ctx, filename);

I tried several approaches as mentioned in different posts but I am not 
able to display this ArrayList of FileObjects. If somebody could outline a list 
of steps to be followed to do this, I would apprecuate it.
Thanks in advance!
-SS


Well, you'll need to expose the objFiles property to the JSP somehow (by 
putting it in request/session scope, or in your form bean, for example). 
Asuming you've done that, and that you have appropriate getters on your 
FileObj, you can access it like this:


logic:iterate id=file name=yourFileObjRef
 bean:write name=file property=fileName/
/logic:iterate

L.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional

Re: logic:iterate tag!

2007-03-09 Thread Swaminathan Subramanian
Hi Laurie!
Thanks for the prompt response. I am pasting code snippets at every level 
(ActionForm, Action class and view). This did not work. Please let me know if I 
am missing something here.
Thanks again!


//*ActionForm class
//core java classes
import java.util.ArrayList;
import java.util.Collection;

// Java extension classes
import javax.servlet.http.HttpServletRequest;
// third-party classes
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
// local project classes
import com.foo.foo1.web.Constants;
import com.foo.foo1.soapcalls.FileObj;
public final class FileReceiptFormBean extends ActionForm
{
 
 // File specific property variables
 
 private String  fileName;
 private String  fileType;
 private String  fileSize;
 private String  fileModifiedDate;
 private String  multipleFiles;
 private String  fileURL;
 private ArrayList alObjFile;
 private FileObj objFile;

 public String  getFileName()
 {
   return (this.fileName);
  }
  public void setFileName(String fileName)
  {
   this.fileName = fileName;
 }
 public String  getfileType()
  {
   return (this.fileType);
  }
  public void setfileType(String fileType)
  {
   this.fileType = fileType;
 }
 public String  getfileSize()
  {
   return (this.fileSize);
  }
  public void setfileSize(String fileSize)
  {
   this.fileSize = fileSize;
 }
  public String  getfileModifiedDate()
  {
   return (this.fileModifiedDate);
  }
  public void setfileModifiedDate(String fileModifiedDate)
  {
   this.fileModifiedDate = fileModifiedDate;
 }
  public String  getmultipleFiles()
  {
   return (this.multipleFiles);
  }
  public void setmultipleFiles(String multipleFiles)
  {
   this.multipleFiles = multipleFiles;
 }
  public String  getfileURL()
  {
   return (this.fileURL);
  }
  public void setfileURL(String fileURL)
  {
   this.fileURL = fileURL;
 }
  public ArrayList  getAlObjFile()
  {
   return (this.alObjFile);
  }
  public void setAlObjFile(ArrayList alObjFile)
  {
   this.alObjFile = alObjFile;
 }
 public FileObj  getObjFile()
  {
   return (this.objFile);
  }
  public void setObjFile(FileObj FileObj)
  {
   this.objFile = objFile;
 }   
   
}

//*End ActionForm class

//*Action class

ArrayList alAFFFile = new ArrayList();
FileObj[] objFiles = null;
objFiles = intf.getFiles(ctx, filename);
String affUrl = ;
for ( int i=0; i  objAFFFiles.length; i++)
{
 affUrl = objFiles[i].fileURL;
 FileReceiptFormBean frfBean = new FileReceiptFormBean();
 frfBean.setFileName(objFiles[i].fileName);
 frfBean.setfileType(objFiles[i].fileType);
 frfBean.setfileSize(objFiles[i].fileSize);
 frfBean.setfileModifiedDate(objFiles[i].fileModifiedDate);
 frfBean.setmultipleFiles(objFiles[i].multipleFiles);
 objFiles[i].fileURL = LoadFileUrlCreator.create(affUrl, application/zip, 
true);
 frfBean.setfileURL(objAFFFiles[i].fileURL);   
 alFile.add(objAFFFiles[i]);
}
session.setAttribute(AFFFiles, alAFFFile);
//*End Action class
//*view.jsp
logic:iterate id=afffiles name=AFFFiles 
 bean:write name=afffiles property=fileName/
/logic:iterate

- Original Message 
From: Laurie Harper [EMAIL PROTECTED]
To: user@struts.apache.org
Sent: Thursday, March 8, 2007 5:11:20 PM
Subject: Re: logic:iterate tag!


Swaminathan Subramanian wrote:
 All,
 I am working on application using Struts 1.0. I am trying to display 
 an ArrayList of complex objects using the logic:iterate tag.
 Here's some more details - 
 
 FileObj
  fileName
  fileSize
  fileType
  fileModifiedDate
 
 Action class
 FileObj[] objFiles = null;
 objFiles = intf.getFiles(ctx, filename);
 
 I tried several approaches as mentioned in different posts but I am 
 not able to display this ArrayList of FileObjects. If somebody could outline 
 a list of steps to be followed to do this, I would apprecuate it.
 Thanks in advance!
 -SS

Well, you'll need to expose the objFiles property to the JSP somehow (by 
putting it in request/session scope, or in your form bean, for example). 
Asuming you've done that, and that you have appropriate getters on your 
FileObj, you can access it like this:

logic:iterate id=file name=yourFileObjRef
 bean:write name=file property=fileName/
/logic:iterate

L.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


 

Be a PS3 game guru.
Get your game face on with the latest PS3 news and previews at Yahoo! Games.
http://videogames.yahoo.com/platform?platform=120121

Re: logic:iterate tag!

2007-03-09 Thread Dave Newton
--- Swaminathan Subramanian wrote:
 ArrayList alAFFFile = new ArrayList();
  alFile.add(objAFFFiles[i]);
 session.setAttribute(AFFFiles, alAFFFile);

Is the alFile.add a typo?

d.



 

Finding fabulous fares is fun.  
Let Yahoo! FareChase search your favorite travel sites to find flight and hotel 
bargains.
http://farechase.yahoo.com/promo-generic-14795097

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: logic:iterate tag!

2007-03-09 Thread Swaminathan Subramanian
I am sorry! It is a typo.

- Original Message 
From: Dave Newton [EMAIL PROTECTED]
To: Struts Users Mailing List user@struts.apache.org
Sent: Friday, March 9, 2007 2:34:26 PM
Subject: Re: logic:iterate tag!


--- Swaminathan Subramanian wrote:
 ArrayList alAFFFile = new ArrayList();
  alFile.add(objAFFFiles[i]);
 session.setAttribute(AFFFiles, alAFFFile);

Is the alFile.add a typo?

d.





Finding fabulous fares is fun.  
Let Yahoo! FareChase search your favorite travel sites to find flight and hotel 
bargains.
http://farechase.yahoo.com/promo-generic-14795097

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


 

Don't get soaked.  Take a quick peek at the forecast
with the Yahoo! Search weather shortcut.
http://tools.search.yahoo.com/shortcuts/#loc_weather

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: logic:iterate tag!

2007-03-08 Thread Laurie Harper

Swaminathan Subramanian wrote:

All,
I am working on application using Struts 1.0. I am trying to display an 
ArrayList of complex objects using the logic:iterate tag.
Here's some more details - 


FileObj
 fileName
 fileSize
 fileType
 fileModifiedDate

Action class
FileObj[] objFiles = null;
objFiles = intf.getFiles(ctx, filename);

I tried several approaches as mentioned in different posts but I am not 
able to display this ArrayList of FileObjects. If somebody could outline a list 
of steps to be followed to do this, I would apprecuate it.
Thanks in advance!
-SS


Well, you'll need to expose the objFiles property to the JSP somehow (by 
putting it in request/session scope, or in your form bean, for example). 
Asuming you've done that, and that you have appropriate getters on your 
FileObj, you can access it like this:


logic:iterate id=file name=yourFileObjRef
bean:write name=file property=fileName/
/logic:iterate

L.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: logic:iterate tag and form beans

2005-08-02 Thread Johnson, Kaerstin

Ok, If I am understanding the question correctly, you should be
populating your array list in your bean with a objects of whatever
represents a table row (such as an employee object), this object should
have the attributes (name, id, address) you would like to render in the
columns. 

Each object in the array will wind up being a table row. 



-Original Message-
From: Brian Kremmin [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 02, 2005 11:02 AM
To: user@struts.apache.org
Subject: logic:iterate tag and form beans

Hello Everyone,

 

This is my first post.  I've been watching the list for a while now and
I've hit a dead end.  This is probably quite simple so any help would be
greatly appreciated.

 

I want to get some table data from a database and output it in table
form on a webpage.

 

I'm planning to use an ArrayList to store the data and use the
logic:iterate tag to expose the elements of the list... however, I'm
unsure of the proper structure of all these data objects.  I think I'm
using struts 1.1 if that makes a difference.

 

I'm assuming I'll create a form bean with an ArrayList as a property..
is this correct?  However, I'm unsure of what sort of objects to put
into the array list.  Do I create another form bean with properties for
each table column, populate a new bean for each row of table data, and
put each into the ArrayList?  Or should the objects in the Arraylist be
something other than a form bean?

 

I'm looking for the 'best' and 'proper practice as our standards group
is very picky.  Any ideas?

 

Thanks




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: logic:iterate tag and form beans

2005-08-02 Thread BHansard
Example:

DataBean:
public class EmployeeBean(){
private String name = null;
Private String dept = null;

... Getters and setters
}

FormBean:
public class EmployeeForm extends ActionForm{
private Collection employees = new ArrayList();
... Getters and Setters
}

ActionClass:

public ActionForward execute(final ActionMapping mapping,
 final ActionForm form,
 final HttpServletRequest request,
 final HttpServletResponse response) {
EmployeeForm empForm = (EmployeeForm) form;

//getEmployeesFromDatabase should return a collection of EmployeeBeans
empForm.setEmployees(getEmployeesFromDatabase());
return mapping.findForward(display);
}


JSP:
table
trthName/th
   thDept/th
html:form action=xyz method=post
logic:iterate id=emp name=EmployeeForm property=employees
trtdhtml:text property=name//td
   tdhtml:text property=dept//td
/tr
/logic:iterate
/html:form





People are conversing... without posting their email or filling 
up their mail box. roomity.com http://roomity.com/launch.jsp No sign up to read 
or search this Rich Internet App
 ~~1122996240050~~



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: logic:iterate tag and form beans

2005-08-02 Thread Dave Newton

Brian Kremmin wrote:


I'm planning to use an ArrayList to store the data and use the
logic:iterate tag to expose the elements of the list... however, I'm
unsure of the proper structure of all these data objects.  I think I'm
using struts 1.1 if that makes a difference.
 

1) I'd tend towards using JSTL rather than the Struts tags when the 
functionality is identical.


2) Put an ArrayList of JavaBeans into the appropriate scope (probably 
request?)


IOW, your ArrayList will contain a collection of JavaBeans with getters 
for each column you want exposed. Say you have a user represented by 
firstname, lastname, and ssn. So your bean would have getFirstname, 
getLastname, and getSsn methods.


In your Action you'd do something like:

request.setAttribute(users, userArrayList);

In your JSP you'd do something like (in JSTL; struts beans are quite 
similar):


table
 c:forEach items=${users} var=user
   tr
 tdc:out value=${user.firstname}/ c:out 
value=${user.lastname}//td

 tdc:out value=${user.ssn}//td
   /tr
 /c:forEach
/table

or whatever.

Again, the hour or two of investment in learning JSTL is worth it for 
tags that don't explicitly need Struts functionality, but on a practical 
level that may not make any difference to you.


Dave



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: logic:iterate tag and form beans

2005-08-02 Thread Laurie Harper

Brian Kremmin wrote:

I want to get some table data from a database and output it in table
form on a webpage.

I'm planning to use an ArrayList to store the data and use the
logic:iterate tag to expose the elements of the list... however, I'm
unsure of the proper structure of all these data objects.  I think I'm
using struts 1.1 if that makes a difference.

I'm assuming I'll create a form bean with an ArrayList as a property..
is this correct?  However, I'm unsure of what sort of objects to put
into the array list.  Do I create another form bean with properties for
each table column, populate a new bean for each row of table data, and
put each into the ArrayList?  Or should the objects in the Arraylist be
something other than a form bean?


If you just need to display the data, you don't need FormBeans or anything 
else Struts-specific. Use whatever data structures make sense to your 
application and pass them to your view (JSP), as others have posted here.


If you need to let the user edit and re-submit the data, validate it, 
re-display it, etc. then you will want to start using FormBeans and the 
rest of the Struts machinery to manage that.


For output-only data, you just need to expose the model (whatever form you 
choose for that). Struts is model-agnostic.



I'm looking for the 'best' and 'proper practice as our standards group
is very picky.  Any ideas?


If you need to satisfy a picky standards group maybe you should ask what 
*they* consider to be the 'correct' way to do this in your organization :-)


L.
--
Laurie, Open Source advocate, Java geek and novice blogger:
http://www.holoweb.net/laurie


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]