struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "hemant" <>
Subject Re: Action Form Dictating Value Objects?
Date Fri, 21 Jun 2002 15:16:38 GMT
Minor correction...It should have been,

Let us take the fruit example.

pardon my grammar

  ----- Original Message ----- 
  From: hemant 
  To: struts 
  Cc: Sanjay Pamidiparti 
  Sent: Friday, June 21, 2002 11:12 AM
  Subject: Action Form Dictating Value Objects?


  Let us take the check the fruit example posted by Larry Maturo. Here the Fruit Object needs
to have a boolean value called checked.

  The ValueObject makes sense when its in a Struts Environment but doesnt it look like we
have compromised on the Value Object definition? the checked instance variable should not
have been there in the first place as it has nothing to do with a "Fruit" abstraction. I guess
we need something like a ValueObject "add on" object to plug it in when we use this Object
in a Struts environment.


  <logic:iterate id="fruits" name="nameOfYourFormBean" property="fruits">
  <html:checkbox indexed="true" name="fruits" property="checked"/>
  <bean:write name="fruits" property="fruitName" />

  in class Fruit
  public class Fruit {
  private String fruitName = "";
  private boolean checked = false;

      public Fruit() {

  public String getFruitName() {
  return fruitName;

  public void setFruitName(String _fruitName) {
  fruitName = _fruitName;

  public boolean getChecked() {
  return checked;

  public void setChecked(boolean _checked){
  checked = _checked;

  In you form bean:

  private ArrayList frutis = null;

  public ArrayList getFruits() {
  return fruits;

  public void setFruits(ArrayList _frutis) {
  fruits = _fruits;

  public Fruit getFruits(int index) {
  return (Fruit) fruits.get(index);

  public void setFruits(int index, Fruit fruit) {

  public void reset(ActionMapping mapping,
                  javax.servlet.http.HttpServletRequest request){
  Fruit f = null;
  Iterator it = fruits.iterator();
  while it.hasNext() {
    f = (Fruit);


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message