You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by William Salvucci <Wi...@dn.netl.doe.gov> on 2003/03/05 22:14:47 UTC

editable list using nested:iterate and lazyList

I posted this already on another thread, but I thought that I would try it again with some more detail.
 
I am trying to create an editable list based on some examples using nested:iterate and ListUtils.lazyList that I have seen offered on this mailing list.
I have created a simple example, the flow of which is detail action -> jsp -> control action. The form that is used by all of these looks like:
 
private List bananas = ListUtils.lazyList(new ArrayList(),
      new Factory()
      {
        public Object create() {
          return new BananaBean();
        }
      });
  public List getBananas() { return bananas; }
 
The detail action adds BananaBean instances using bananas.add. Inside a nested:form on the jsp I have
 
<nested:iterate property="bananas">
    <nested:text property="flavour"/>
  </nested:iterate>
 
and in the control action, I do form.getBananas() and print out the values to see if they reflect the changes I made on the page.
 
I can't even successfully display the jsp. I get the following exception:
java.lang.IllegalArgumentException: Property 'bananas' is not indexed 
 
I can't think of a simplier example. Any ideas?
 
I'm using nested_tags_10.jar with 1.3.1
 
BTW: LazyList implements Collection so it's indexed, right?


Re: editable list using nested:iterate and lazyList

Posted by alexj <al...@freesurf.ch>.
I give a sample is use when I need to populate an view :

I got an ActionForm :

public class StudentForm extends ActionForm {

private String formationSelected = "Analyste Programmeur";

private Collection formationList = null;


private Collection formationListID = null;


private Collection groupList = null;


private Collection groupListID = null;

private String group = "cycle 1a";


......

......

/**

* Get the formationList.

* @return Collection.

*/

public Collection getFormationList () {


formationList = Formation.getFormations();

return formationList;

}



/**

* Get the formationListID.

* @return Collection.

*/

public Collection getFormationListID () {


formationListID = Formation.getFormationsID();

return formationListID;

}

/**

* Get the groupList.

* @return Collection.

*/



public Collection getGroupList () {


groupList = Groupe.getGroupsOfStudent();

return groupList;

}



/**

* Get the groupList.

* @return Collection.

*/



public Collection getGroupListID () {

groupListID = Groupe.getGroupID();

return groupListID;

}

..

I got an viewstudent action :

public ActionForward execute(

ActionMapping mapping,

ActionForm form,

HttpServletRequest request,

HttpServletResponse response)

throws Exception {

Collection students = null;

StudentForm studentForm = (StudentForm) form;

students = getStudents ();

HttpSession session = request.getSession();

session.setAttribute("students", students);

return mapping.findForward("viewstudent");

}



/**

* Get all students.

*/

protected ArrayList getStudents () {


return Student.getStudents();

}

And my jsp view for studentview is :

<%@ page session="true" %>
<%@ page import="org.apache.taglibs.display.test.TestList,
                 org.apache.taglibs.display.test.ListHolder,
                 java.util.List"%>
<%@ taglib uri="http://jakarta.apache.org/taglibs/display" prefix="display"
%>
<%@ taglib uri="/WEB-INF/struts-menu.tld" prefix="menu"%>

<html>
    <head>
    </head>

<body>
  <script language="JavaScript1.2" src="./scripts/coolmenus3.js">
  </script>
  <script src="./scripts/coolmenu-config.js">
</script>

<menu:useMenuDisplayer name="CoolMenu"

             bundle="org.apache.struts.action.MESSAGE">


    <menu:displayMenu name="ToDoListMenuFile"/>
    <menu:displayMenu name="ToDoListMenuEdit"/>
    <menu:displayMenu name="CaseDetailMenuCase"/>
</menu:useMenuDisplayer>
<p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>

<display:table width="85%"align="left"
              name="students"
              scope="session"
              pagesize="5"
              requestURI="/ibmss/form/viewstudent.jsp"
              export="true"
              decorator="org.apache.taglibs.display.test.Wrapper">

  <display:column property="idPersonne" title="ID"
                  href="/ibmss/getstudent.do"
                  paramId="idPersonne"
                  paramProperty="idPersonne"  />
  <display:column property="name" title="Nom"/>
  <display:column property="firstName" title="Prénom"/>
  <display:column property="adress" title="Adresse"/>
  <display:column property="city" title="Ville"/>
  <display:column property="npa" title="Npa"/>
  <display:column property="phoneNumber" title="Telephone"/>
  <display:column property="email" title="Email" autolink="true"/>
  <display:column property="insuranceName" title="Assurance"/>
  <display:column property="insuranceNumber" title="No assure"/>
  <display:column property="formationSelected" title="Formation"/>
  <display:column property="group" title="Groupe"/>
</display:table>

</body>
</html>

The getstudent action serve me to get

the student an user who whant to edit him

I got an getstudentaction who create a new

studentform and populate this form with

the data of the choosen student previously

selected.



I hope this can help you.

--

Alexandre Jaquet

----- Original Message -----
From: "William Salvucci" <Wi...@dn.netl.doe.gov>
To: <st...@jakarta.apache.org>
Sent: Wednesday, March 05, 2003 10:14 PM
Subject: editable list using nested:iterate and lazyList


I posted this already on another thread, but I thought that I would try it
again with some more detail.

I am trying to create an editable list based on some examples using
nested:iterate and ListUtils.lazyList that I have seen offered on this
mailing list.
I have created a simple example, the flow of which is detail action ->
jsp -> control action. The form that is used by all of these looks like:

private List bananas = ListUtils.lazyList(new ArrayList(),
      new Factory()
      {
        public Object create() {
          return new BananaBean();
        }
      });
  public List getBananas() { return bananas; }

The detail action adds BananaBean instances using bananas.add. Inside a
nested:form on the jsp I have

<nested:iterate property="bananas">
    <nested:text property="flavour"/>
  </nested:iterate>

and in the control action, I do form.getBananas() and print out the values
to see if they reflect the changes I made on the page.

I can't even successfully display the jsp. I get the following exception:
java.lang.IllegalArgumentException: Property 'bananas' is not indexed

I can't think of a simplier example. Any ideas?

I'm using nested_tags_10.jar with 1.3.1

BTW: LazyList implements Collection so it's indexed, right?



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: editable list using nested:iterate and lazyList

Posted by alexj <al...@freesurf.ch>.
A collection use an iterator, an collection who use an array for it's
internal structure use an index.

If you use an invalid collection you will got an cannot create iterator
for bean ....

If you use an in-proper Array structure you will got an exception could
not create index.

I got a question why do you use an LazyList ????

--
Alexandre Jaquet

----- Original Message -----
From: "William Salvucci" <Wi...@dn.netl.doe.gov>
To: <st...@jakarta.apache.org>
Sent: Wednesday, March 05, 2003 10:14 PM
Subject: editable list using nested:iterate and lazyList


I posted this already on another thread, but I thought that I would try it
again with some more detail.

I am trying to create an editable list based on some examples using
nested:iterate and ListUtils.lazyList that I have seen offered on this
mailing list.
I have created a simple example, the flow of which is detail action ->
jsp -> control action. The form that is used by all of these looks like:

private List bananas = ListUtils.lazyList(new ArrayList(),
      new Factory()
      {
        public Object create() {
          return new BananaBean();
        }
      });
  public List getBananas() { return bananas; }

The detail action adds BananaBean instances using bananas.add. Inside a
nested:form on the jsp I have

<nested:iterate property="bananas">
    <nested:text property="flavour"/>
  </nested:iterate>

and in the control action, I do form.getBananas() and print out the values
to see if they reflect the changes I made on the page.

I can't even successfully display the jsp. I get the following exception:
java.lang.IllegalArgumentException: Property 'bananas' is not indexed

I can't think of a simplier example. Any ideas?

I'm using nested_tags_10.jar with 1.3.1

BTW: LazyList implements Collection so it's indexed, right?



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: editable list using nested:iterate and lazyList

Posted by alexj <al...@freesurf.ch>.
But maybe I'm wrong because I've done to much programming with Eiffel...

--
Alexandre Jaquet

----- Original Message -----
From: "William Salvucci" <Wi...@dn.netl.doe.gov>
To: <st...@jakarta.apache.org>
Sent: Wednesday, March 05, 2003 10:14 PM
Subject: editable list using nested:iterate and lazyList


I posted this already on another thread, but I thought that I would try it
again with some more detail.

I am trying to create an editable list based on some examples using
nested:iterate and ListUtils.lazyList that I have seen offered on this
mailing list.
I have created a simple example, the flow of which is detail action ->
jsp -> control action. The form that is used by all of these looks like:

private List bananas = ListUtils.lazyList(new ArrayList(),
      new Factory()
      {
        public Object create() {
          return new BananaBean();
        }
      });
  public List getBananas() { return bananas; }

The detail action adds BananaBean instances using bananas.add. Inside a
nested:form on the jsp I have

<nested:iterate property="bananas">
    <nested:text property="flavour"/>
  </nested:iterate>

and in the control action, I do form.getBananas() and print out the values
to see if they reflect the changes I made on the page.

I can't even successfully display the jsp. I get the following exception:
java.lang.IllegalArgumentException: Property 'bananas' is not indexed

I can't think of a simplier example. Any ideas?

I'm using nested_tags_10.jar with 1.3.1

BTW: LazyList implements Collection so it's indexed, right?



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org