RE: Posting Collections

2001-05-11 Thread Tony Karas

Thanks Niall.

I'm currently frustrated because I'm finding it hard to discover all the 
information I require.  Seems to be a general lack of documentation on 
struts usage, but it's a learning curve like anything else.

I like Struts in principle, and what it is trying to achieve, I just 
wondered if you considered it ready for building a large-scale project.  For 
example, this change that you have submitted is going to affect a lot of 
code.  So my options are to stick to my current solution without changing 
any of the Struts code, or modify the code so that it does what I want in 
the hope that the change will get propagated through to the next release.  
It doesn't feel like a good way to be working, but I take your point about 
Open Source, and I partly agree.

For the time being I'm going to persevere - and I look forward to seeing 
your custom tags so I don't have to hack around with the code every time a 
new version comes out.

Cheers ;-)

Tony


From: Niall Pemberton [EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: RE: Posting Collections
Date: Thu, 10 May 2001 20:23:31 +0100

This issue applies to all form field tags, not just checkboxes.

Modifying struts tags is currently a pain, but I just subimitted a bugzilla
enhancement to re-factor the tags so that they are more granualar and make
it easier to override descrete bits such as generating the name attribute.
In principle the enhacement has been accepted and I hope to submit a patch
in the next few days. If it is accepted I will have a set of custom 
versions
of these tags for this behviour very soon and you won't have to start
hacking around with the code every time a new version comes out and anyone
will be welcome to them.

Addtionally this issue is all on the ToDo list for 1.1 and I'm sure it
will be sorted then.

I think struts is excellent, and I love open source because you can always
look inside to see what they've done. Of course it doesn't do everything 
yet
;-) but I can't see it getting anything but better. We have done quite a 
bit
of work customizing the ActionServlet and the way its been built is
excellent, making it really easy to add addtional behaviour (hopefully)
without having to hack around every time a new version comes out.

Niall

  -Original Message-
  From: Tony Karas [mailto:[EMAIL PROTECTED]]
  Sent: 10 May 2001 10:34
  To: [EMAIL PROTECTED]
  Subject: RE: Posting Collections
 
 
  Many thanks Niall, that clears things up for me.  Do you know if
  there is a
  reason why this is the behaviour for checkboxes?  Is this just with
  checkboxes or other tags as well?
 
  I don't really like the idea of modifying the struts code - the
  whole point
  of deciding to use it is for code reuse - I don't want to start hacking
  around with the code every time a new version comes out.
 
  Do you have an opinion on using Struts?  I've been using it for a
  couple of
  weeks now and have been struggling because of basic lack of
  information.  I
  get most of my training from this news group!  I'm wondering whether I
  should just jack it in and use something else.
 
  Cheers
  Tony
 
 
  From: Niall Pemberton [EMAIL PROTECTED]
  Reply-To: [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Subject: RE: Posting Collections
  Date: Wed, 9 May 2001 20:51:00 +0100
  
  The problem is the CheckBox tag currently sets the HTML name attribute 
to
  the property, so your JSP will produced something like this:
  
   input type=checkbox name=delete
  
  So all the checkbox fields will have the same name.
  
  In order for Struts to populate your Retailer bean with the delete 
values
  you need the generated HTML to look like this:
  
   input type=checkbox name=retailer[0].delete
   input type=checkbox name=retailer[1].delete etc etc.
  
  Struts would then use getRetailer(0).setDelete(boolean) to set the 
delete
  attributes correctly.
  
  Unfortunately there is no easy solution - many people resort to
  scriptlets
  to generate the name properly and there are quite a few messages in the
  archive about this.
  
  I created my own versions of Struts tags and changed them to generate 
the
  name correctly - I like that much better - no java in the view.
  
  Niall
  
-Original Message-
From: Tony Karas [mailto:[EMAIL PROTECTED]]
Sent: 09 May 2001 17:50
To: [EMAIL PROTECTED]
Subject: Posting Collections
   
   
Briefly, this is what I am trying to achieve:
   
- Retrieve a list of items from a database
- Display each item with a corresponding checkbox
- Display a Delete button - which when pressed deletes all
checked items.
   
Unfortunately, although I have managed to display the items 
correctly
  and
set the checkbox value using boolean values, when I do the form
submit - my
ActionForm properties do not get filled in.
   
This is the code I have:
   
My ActionForm looks like this:
   
public class

RE: Posting Collections

2001-05-10 Thread Tony Karas

Many thanks Niall, that clears things up for me.  Do you know if there is a 
reason why this is the behaviour for checkboxes?  Is this just with 
checkboxes or other tags as well?

I don't really like the idea of modifying the struts code - the whole point 
of deciding to use it is for code reuse - I don't want to start hacking 
around with the code every time a new version comes out.

Do you have an opinion on using Struts?  I've been using it for a couple of 
weeks now and have been struggling because of basic lack of information.  I 
get most of my training from this news group!  I'm wondering whether I 
should just jack it in and use something else.

Cheers
Tony


From: Niall Pemberton [EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: RE: Posting Collections
Date: Wed, 9 May 2001 20:51:00 +0100

The problem is the CheckBox tag currently sets the HTML name attribute to
the property, so your JSP will produced something like this:

 input type=checkbox name=delete

So all the checkbox fields will have the same name.

In order for Struts to populate your Retailer bean with the delete values
you need the generated HTML to look like this:

 input type=checkbox name=retailer[0].delete
 input type=checkbox name=retailer[1].delete etc etc.

Struts would then use getRetailer(0).setDelete(boolean) to set the delete
attributes correctly.

Unfortunately there is no easy solution - many people resort to scriptlets
to generate the name properly and there are quite a few messages in the
archive about this.

I created my own versions of Struts tags and changed them to generate the
name correctly - I like that much better - no java in the view.

Niall

  -Original Message-
  From: Tony Karas [mailto:[EMAIL PROTECTED]]
  Sent: 09 May 2001 17:50
  To: [EMAIL PROTECTED]
  Subject: Posting Collections
 
 
  Briefly, this is what I am trying to achieve:
 
  - Retrieve a list of items from a database
  - Display each item with a corresponding checkbox
  - Display a Delete button - which when pressed deletes all
  checked items.
 
  Unfortunately, although I have managed to display the items correctly 
and
  set the checkbox value using boolean values, when I do the form
  submit - my
  ActionForm properties do not get filled in.
 
  This is the code I have:
 
  My ActionForm looks like this:
 
  public class RetailerForm extends ActionForm
  {
  protected Vector retailer;
 
  /*
   * On construction, fill the form with all the retailers
   */
  public RetailerForm() throws SQLException
  {
   //here i have some code to generate my vector
   //which is comprised of Retailer beans.
  }
 
  public Retailer getRetailer( int index )
  {
  return (Retailer)retailer.elementAt( index );
  }
 
  public Vector getRetailer()
  {
  return retailer;
  }
 
  public void setRetailer( Vector value )
  {
  retailer = value;
  }
  }
 
  My Retailer bean has get and set elements for properties called
  delete
  and name.
 
  My struts code looks like this (obviously within html:form tags):
 
  logic:iterate id=retailer name=retailerForm property=retailer
  tr
  tdhtml:checkbox name=retailer property=delete//td
  tdbean:write name=retailer property=name//td
  /tr
  /logic:iterate
 
  And this all works ok for displaying the data.  However, when I do the
  submit my delete property for each bean is not set and I have added
  debugging code to the set method and this is not called by struts.  I
  don't get error messages - it just doesn't happen.
 
  I know other people have had this problem, but I am struggling to find a
  solution.
 
  Can anyone help me?  Is there a better way of achieving what I am
  trying to
  achieve?  If I am doing the correct thing, what's the reason it's not
  working.
 
  All help appreciated.
 
  Cheers
  Tony
  
_
  Get Your Private, Free E-mail from MSN Hotmail at 
http://www.hotmail.com.
 
 


_
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.




RE: Posting Collections

2001-05-10 Thread Niall Pemberton

This issue applies to all form field tags, not just checkboxes.

Modifying struts tags is currently a pain, but I just subimitted a bugzilla
enhancement to re-factor the tags so that they are more granualar and make
it easier to override descrete bits such as generating the name attribute.
In principle the enhacement has been accepted and I hope to submit a patch
in the next few days. If it is accepted I will have a set of custom versions
of these tags for this behviour very soon and you won't have to start
hacking around with the code every time a new version comes out and anyone
will be welcome to them.

Addtionally this issue is all on the ToDo list for 1.1 and I'm sure it
will be sorted then.

I think struts is excellent, and I love open source because you can always
look inside to see what they've done. Of course it doesn't do everything yet
;-) but I can't see it getting anything but better. We have done quite a bit
of work customizing the ActionServlet and the way its been built is
excellent, making it really easy to add addtional behaviour (hopefully)
without having to hack around every time a new version comes out.

Niall

 -Original Message-
 From: Tony Karas [mailto:[EMAIL PROTECTED]]
 Sent: 10 May 2001 10:34
 To: [EMAIL PROTECTED]
 Subject: RE: Posting Collections


 Many thanks Niall, that clears things up for me.  Do you know if
 there is a
 reason why this is the behaviour for checkboxes?  Is this just with
 checkboxes or other tags as well?

 I don't really like the idea of modifying the struts code - the
 whole point
 of deciding to use it is for code reuse - I don't want to start hacking
 around with the code every time a new version comes out.

 Do you have an opinion on using Struts?  I've been using it for a
 couple of
 weeks now and have been struggling because of basic lack of
 information.  I
 get most of my training from this news group!  I'm wondering whether I
 should just jack it in and use something else.

 Cheers
 Tony


 From: Niall Pemberton [EMAIL PROTECTED]
 Reply-To: [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Subject: RE: Posting Collections
 Date: Wed, 9 May 2001 20:51:00 +0100
 
 The problem is the CheckBox tag currently sets the HTML name attribute to
 the property, so your JSP will produced something like this:
 
  input type=checkbox name=delete
 
 So all the checkbox fields will have the same name.
 
 In order for Struts to populate your Retailer bean with the delete values
 you need the generated HTML to look like this:
 
  input type=checkbox name=retailer[0].delete
  input type=checkbox name=retailer[1].delete etc etc.
 
 Struts would then use getRetailer(0).setDelete(boolean) to set the delete
 attributes correctly.
 
 Unfortunately there is no easy solution - many people resort to
 scriptlets
 to generate the name properly and there are quite a few messages in the
 archive about this.
 
 I created my own versions of Struts tags and changed them to generate the
 name correctly - I like that much better - no java in the view.
 
 Niall
 
   -Original Message-
   From: Tony Karas [mailto:[EMAIL PROTECTED]]
   Sent: 09 May 2001 17:50
   To: [EMAIL PROTECTED]
   Subject: Posting Collections
  
  
   Briefly, this is what I am trying to achieve:
  
   - Retrieve a list of items from a database
   - Display each item with a corresponding checkbox
   - Display a Delete button - which when pressed deletes all
   checked items.
  
   Unfortunately, although I have managed to display the items correctly
 and
   set the checkbox value using boolean values, when I do the form
   submit - my
   ActionForm properties do not get filled in.
  
   This is the code I have:
  
   My ActionForm looks like this:
  
   public class RetailerForm extends ActionForm
   {
   protected Vector retailer;
  
   /*
* On construction, fill the form with all the retailers
*/
   public RetailerForm() throws SQLException
   {
//here i have some code to generate my vector
//which is comprised of Retailer beans.
   }
  
   public Retailer getRetailer( int index )
   {
   return (Retailer)retailer.elementAt( index );
   }
  
   public Vector getRetailer()
   {
   return retailer;
   }
  
   public void setRetailer( Vector value )
   {
   retailer = value;
   }
   }
  
   My Retailer bean has get and set elements for properties called
   delete
   and name.
  
   My struts code looks like this (obviously within html:form tags):
  
   logic:iterate id=retailer name=retailerForm property=retailer
 tr
 tdhtml:checkbox name=retailer property=delete//td
 tdbean:write name=retailer property=name//td
 /tr
   /logic:iterate
  
   And this all works ok for displaying the data.  However, when I do the
   submit my delete property for each bean is not set and I have added
   debugging code to the set method and this is not called

Posting Collections

2001-05-09 Thread Tony Karas

Briefly, this is what I am trying to achieve:

- Retrieve a list of items from a database
- Display each item with a corresponding checkbox
- Display a Delete button - which when pressed deletes all checked items.

Unfortunately, although I have managed to display the items correctly and 
set the checkbox value using boolean values, when I do the form submit - my 
ActionForm properties do not get filled in.

This is the code I have:

My ActionForm looks like this:

public class RetailerForm extends ActionForm
{
protected Vector retailer;

/*
 * On construction, fill the form with all the retailers
 */
public RetailerForm() throws SQLException
{
 //here i have some code to generate my vector
 //which is comprised of Retailer beans.
}

public Retailer getRetailer( int index )
{
return (Retailer)retailer.elementAt( index );
}

public Vector getRetailer()
{
return retailer;
}

public void setRetailer( Vector value )
{
retailer = value;
}
}

My Retailer bean has get and set elements for properties called delete 
and name.

My struts code looks like this (obviously within html:form tags):

logic:iterate id=retailer name=retailerForm property=retailer
tr
tdhtml:checkbox name=retailer property=delete//td
tdbean:write name=retailer property=name//td
/tr
/logic:iterate

And this all works ok for displaying the data.  However, when I do the 
submit my delete property for each bean is not set and I have added 
debugging code to the set method and this is not called by struts.  I 
don't get error messages - it just doesn't happen.

I know other people have had this problem, but I am struggling to find a 
solution.

Can anyone help me?  Is there a better way of achieving what I am trying to 
achieve?  If I am doing the correct thing, what's the reason it's not 
working.

All help appreciated.

Cheers
Tony
_
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.




RE: Posting Collections

2001-05-09 Thread Niall Pemberton

The problem is the CheckBox tag currently sets the HTML name attribute to
the property, so your JSP will produced something like this:

input type=checkbox name=delete

So all the checkbox fields will have the same name.

In order for Struts to populate your Retailer bean with the delete values
you need the generated HTML to look like this:

input type=checkbox name=retailer[0].delete
input type=checkbox name=retailer[1].delete etc etc.

Struts would then use getRetailer(0).setDelete(boolean) to set the delete
attributes correctly.

Unfortunately there is no easy solution - many people resort to scriptlets
to generate the name properly and there are quite a few messages in the
archive about this.

I created my own versions of Struts tags and changed them to generate the
name correctly - I like that much better - no java in the view.

Niall

 -Original Message-
 From: Tony Karas [mailto:[EMAIL PROTECTED]]
 Sent: 09 May 2001 17:50
 To: [EMAIL PROTECTED]
 Subject: Posting Collections


 Briefly, this is what I am trying to achieve:

 - Retrieve a list of items from a database
 - Display each item with a corresponding checkbox
 - Display a Delete button - which when pressed deletes all
 checked items.

 Unfortunately, although I have managed to display the items correctly and
 set the checkbox value using boolean values, when I do the form
 submit - my
 ActionForm properties do not get filled in.

 This is the code I have:

 My ActionForm looks like this:

 public class RetailerForm extends ActionForm
 {
 protected Vector retailer;

 /*
  * On construction, fill the form with all the retailers
  */
 public RetailerForm() throws SQLException
 {
  //here i have some code to generate my vector
  //which is comprised of Retailer beans.
 }

 public Retailer getRetailer( int index )
 {
 return (Retailer)retailer.elementAt( index );
 }

 public Vector getRetailer()
 {
 return retailer;
 }

 public void setRetailer( Vector value )
 {
 retailer = value;
 }
 }

 My Retailer bean has get and set elements for properties called
 delete
 and name.

 My struts code looks like this (obviously within html:form tags):

 logic:iterate id=retailer name=retailerForm property=retailer
   tr
   tdhtml:checkbox name=retailer property=delete//td
   tdbean:write name=retailer property=name//td
   /tr
 /logic:iterate

 And this all works ok for displaying the data.  However, when I do the
 submit my delete property for each bean is not set and I have added
 debugging code to the set method and this is not called by struts.  I
 don't get error messages - it just doesn't happen.

 I know other people have had this problem, but I am struggling to find a
 solution.

 Can anyone help me?  Is there a better way of achieving what I am
 trying to
 achieve?  If I am doing the correct thing, what's the reason it's not
 working.

 All help appreciated.

 Cheers
 Tony
 _
 Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.






RE: Posting Collections

2001-05-09 Thread Niall Pemberton

The problem is the CheckBox tag currently sets the HTML name attribute to
the property, so your JSP will produced something like this:

input type=checkbox name=delete

So all the checkbox fields will have the same name.

In order for Struts to populate your Retailer bean with the delete values
you need the generated HTML to look like this:

input type=checkbox name=retailer[0].delete
input type=checkbox name=retailer[1].delete etc etc.

Struts would then use getRetailer(0).setDelete(boolean) to set the delete
attributes correctly.

Unfortunately there is no easy solution - many people resort to scriptlets
to generate the name properly and there are quite a few messages in the
archive about this.

I created my own versions of Struts tags and changed them to generate the
name correctly - I like that much better - no java in the view.

Niall

 -Original Message-
 From: Tony Karas [mailto:[EMAIL PROTECTED]]
 Sent: 09 May 2001 17:50
 To: [EMAIL PROTECTED]
 Subject: Posting Collections


 Briefly, this is what I am trying to achieve:

 - Retrieve a list of items from a database
 - Display each item with a corresponding checkbox
 - Display a Delete button - which when pressed deletes all
 checked items.

 Unfortunately, although I have managed to display the items correctly and
 set the checkbox value using boolean values, when I do the form
 submit - my
 ActionForm properties do not get filled in.

 This is the code I have:

 My ActionForm looks like this:

 public class RetailerForm extends ActionForm
 {
 protected Vector retailer;

 /*
  * On construction, fill the form with all the retailers
  */
 public RetailerForm() throws SQLException
 {
  //here i have some code to generate my vector
  //which is comprised of Retailer beans.
 }

 public Retailer getRetailer( int index )
 {
 return (Retailer)retailer.elementAt( index );
 }

 public Vector getRetailer()
 {
 return retailer;
 }

 public void setRetailer( Vector value )
 {
 retailer = value;
 }
 }

 My Retailer bean has get and set elements for properties called
 delete
 and name.

 My struts code looks like this (obviously within html:form tags):

 logic:iterate id=retailer name=retailerForm property=retailer
   tr
   tdhtml:checkbox name=retailer property=delete//td
   tdbean:write name=retailer property=name//td
   /tr
 /logic:iterate

 And this all works ok for displaying the data.  However, when I do the
 submit my delete property for each bean is not set and I have added
 debugging code to the set method and this is not called by struts.  I
 don't get error messages - it just doesn't happen.

 I know other people have had this problem, but I am struggling to find a
 solution.

 Can anyone help me?  Is there a better way of achieving what I am
 trying to
 achieve?  If I am doing the correct thing, what's the reason it's not
 working.

 All help appreciated.

 Cheers
 Tony
 _
 Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.






RE: Posting Collections

2001-05-09 Thread Deadman, Hal

I think I am doing the same thing that you want to do using the
html:multibox. When the form is submitted you get an array of the ids that
are checked and then you can go delete them.

in the jsp form (where restaurant id is a key for the item being deleted):
logic:iterate id=restaurant name=favoriterestaurants
...
html:multibox property=favoriteRestaurantRemoveList
bean:write property=restaurantId name=restaurant/
/html:multibox
...
/logic:iterate


in the form class:
private Long favoriteRestaurantRemoveList[] = new Long[0];

public Long[] getFavoriteRestaurantRemoveList() {
return (this.favoriteRestaurantRemoveList);
}

public void setFavoriteRestaurantRemoveList(Long
favoriteRestaurantRemoveList[]) {
this.favoriteRestaurantRemoveList = favoriteRestaurantRemoveList;
}

I am not sure if initializing the array to new Long[0] is necessary,
probably not.

 -Original Message-
 From: Tony Karas [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, May 09, 2001 12:50 PM
 To: [EMAIL PROTECTED]
 Subject: Posting Collections


 Briefly, this is what I am trying to achieve:

 - Retrieve a list of items from a database
 - Display each item with a corresponding checkbox
 - Display a Delete button - which when pressed deletes all
 checked items.

 Unfortunately, although I have managed to display the items
 correctly and
 set the checkbox value using boolean values, when I do the
 form submit - my
 ActionForm properties do not get filled in.

 This is the code I have:

 My ActionForm looks like this:

 public class RetailerForm extends ActionForm
 {
 protected Vector retailer;

 /*
  * On construction, fill the form with all the retailers
  */
 public RetailerForm() throws SQLException
 {
  //here i have some code to generate my vector
  //which is comprised of Retailer beans.
 }

 public Retailer getRetailer( int index )
 {
 return (Retailer)retailer.elementAt( index );
 }

 public Vector getRetailer()
 {
 return retailer;
 }

 public void setRetailer( Vector value )
 {
 retailer = value;
 }
 }

 My Retailer bean has get and set elements for properties
 called delete
 and name.

 My struts code looks like this (obviously within html:form tags):

 logic:iterate id=retailer name=retailerForm property=retailer
   tr
   tdhtml:checkbox name=retailer property=delete//td
   tdbean:write name=retailer property=name//td
   /tr
 /logic:iterate

 And this all works ok for displaying the data.  However, when
 I do the
 submit my delete property for each bean is not set and I have added
 debugging code to the set method and this is not called by
 struts.  I
 don't get error messages - it just doesn't happen.

 I know other people have had this problem, but I am
 struggling to find a
 solution.

 Can anyone help me?  Is there a better way of achieving what
 I am trying to
 achieve?  If I am doing the correct thing, what's the reason it's not
 working.

 All help appreciated.

 Cheers
 Tony
 __
 ___
 Get Your Private, Free E-mail from MSN Hotmail at
http://www.hotmail.com.