views:

35

answers:

1

Hi,

I have been developing a piece of simulation software using Struts 1.3/JSP. I am trying to find a way to display of list of objects on my JSP page which can be added to/deleted from. I actually have a list of chemical steps, each step has a list of product and reactant species (species is also a java object)

This is the Step class:

public class ChemicalStep {
    private List<Species> reactants = new ArrayList<Species>;
    private List<Species> products = new ArrayList<Species>;

// Getters and setters etc

}

This is the species class:

public Class Species {
    private String name;

    // Getter and setters etc

}

Finally here is the relevant part of the ActionForm:

public class StepForm extends ActionForm{
    private List<ChemicalStep> steps = new ArrayList<ChemicalStep>();

   // Getters and setters etc
}

I am looking for a way to dynamically show the chemical steps and to use an action class to add and remove them from the list.

What I want is a table shown the steps and then an add button, when this is clicked I need to show a new step with buttons to add/remove species objects from each list on the step object. The JSP needs to render as many text boxes for the names as there are species in the list.

I know this is a long winded problem. I would welcome any thoughts that anyone has on it!

A: 

Your problem has nothing to do with struts if you want to do this dynamically.

You need to explore a Javascript/Ajax library.

There are a gazillion of them, so I would suggest you start with jQuery.

kazanaki
Dynamically != Asynchrounously. This is perfectly and easy doable using plain vanilla HTML/JSP/Servlet. Unfortunately I can't post a specific answer since I don't do Struts. Seeing the lack of Struts experts here, one should also not expect a Struts-targeted answer soon enough.
BalusC
He says that he needs an "add" button that modifies the page on the fly and adds more controls (a new "step"). Doesn't this require Javascript?Am I missing something?
kazanaki