开发者

Maintaining a list of Objects on a JSP page

开发者 https://www.devze.com 2023-01-06 05:13 出处:网络
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

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开发者_如何学Go 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!


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号