How to use overloaded methods in JSPs

Tags: #<Tag:0x00007f0f19f2a6a0> #<Tag:0x00007f0f19f2a560>

Platform Version: 1.10.2 Module: radiologydcm4chee

Hey there! I am currently developing on the dcm4chee module. I want to create an encounter for an observation. For this encounter I need a provider. When I try to bind the provider like this:

                <td>Obs Encounter Provider</td>
                <td><spring:bind path="obs.encounter.provider">
                        <openmrs:fieldGen type="org.openmrs.Provider"
                            val="${obs.encounter.provider}" />

The method setProvider(Person provider) gets called in Encounter. This leads me to my final question:

How can I call other, overloaded, implementations of the setProvider method? Especially setProvider(EncounterRole role, Provider provider).

I believe that what you’re asking is not possible.

I haven’t gone back and re-read the Spring docs, but I’m pretty sure you can only spring:bind to a plain bean property.

And generally, JSTL cannot call arbitrary methods.

In Struts (and I guess Spring does the same) it doesn’t need to be a real property. As long as there’s a setter and getter it works.

@lluismf is correct, I phrased it incorrectly. You can only spring:bind to something with a standard bean-convention getter and setter.

But regardless you can’t call setProvider(EncounterRole, Provider) via spring:bind.

If the encounter role is fixed, you could add in Encounter a getEncounterRolesMap returning a Map<String, EncounterRole> (and its corresponding setter) and then do something like:

 <spring:bind path="obs.encounter.encounterRolesMap[roleUUID].provider">

But I don’t think it’s a good idea to add new methods to the domain objects for a specific JSP need. In fact, I don’t like the idea of using domain objects in the view but that’s another question.

Thank you @darius and @lluismf :smile:

I’m going to find another way then, I guess.