• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Struts and using methods from a service

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

First time here and learning Struts. I have a project using struts 2 and a service another co-worker created. The action instantiates the service and calls a method which returns an array list of objects. This is for a home health care company, so I pass into the service a patient's id number, and it returns a list of visits made to that patient's home. I was able to iterate through and display the visit information. There are a few things I want to do.

Part of the visit information is the id of the person who made the visit. The service has a method that given the id, will retrieve the employee object associated with that id.
a) how do I pass in each visit's employee id.
b) how do I display information from that employee (name, date hired, discipline - speech therapist for example).
c) later I want to do this with the physicians the person is allowed to use (the parameters will be the location and the discipline needed - podiatry for example). This will return a list which I have to iterate through and populate a drop down.

So far my action has only the execute method which like I said instantiates the service and calls the "getAllVisits" method (I hardcoded a patient id here - I will change this to get the id from the request or session. This is an enhancement so by the time they are at my new screen, the patient has already been selected and is in the request/session). I have a system.out.println for debugging which displays how many records were returned from the call. I noticed that in console, this line appears 6 times which happens to be the number of records returned. Is this supposed to happen?

 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem is undoubtedly your co-worker. And you can tell him I said so.

Your best bet is to do all of this on the server side; but how best to do that depends on other details. If it's returning Hibernate data, and the mapping is set up properly, you can just Hibernate.initialize() the patient's visit's employee(s). You probably do *not* want to do that in the JSP even if you're using the open session in view filter (I don't remember if we were using that or not); that would be inefficient.

You display the information the same way: regardless of how the data is retrieved, as long as it's associated with the patient, just iterate over it. The same thing for the physician list, although you don't need to iterate over that manually, you can use an s:select tag (or do it manually if you're not using the S2 form tags).
 
reply
    Bookmark Topic Watch Topic
  • New Topic