If you need to call a bean method, it's a sign of a design problem. Either you are trying to do something in the JSP that should be handled by the page controller, or your bean has a design problem. Beans should have getters and setters -- general methods violate the bean pattern.
Basically I have an assignment where I need to create a dynamic table that represents a time sheet. Employees can login, makes changes to time sheets, and save them to the remote database. Employees can also click "Add a Row" to add a new row to the time sheet. So I've created a bean to represent the table with an 2D array list of TSCells. Each TSCell object has coordinates (as an ID) and data. In the JSP page, I create and populate an HTML table filled with text inputs.
At the moment I'm having 2 issues:
1. Saving to the column value because I can't figure out how access the TSCell's setData() method in JSP because it's in an ArrayList, there's no "bean" I can use for it. Is there a way to reference an existing bean? Can I use EL to access it?
2. Every time I add a row by clicking the "Add Row" button, the form action sends the input to the "ts_process.jsp" page, which forwards back to the original. The row is added, but I can't add additional rows. I seem to be stuck on the ts_process.jsp page or something.
3. I still can't find a way to call the bean method "Add Row" without using scriptlets (<% tags with pure Java). Is there a way? Or is it just poor design as you've said?
I'm not looking for someone to do my assignment for me, I want to learn. I just can't seem to find specific answers to my questions online. So how would I go about solving these issues? Is it possible? Should I change my design from a table class to multiple objects (e.g. have time sheet entry objects with data members for each column)?
I'm calling this one solved. The only way to call a bean method is to use EL. As for the rest, I made some minor mistakes with my code that have been corrected (i.e. accidentally setting the scope to request instead of session).
Thanks to all who replied.
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop