Search code examples
jstlstripesdynamic-import

Multiple c:imports with Stripes is causing problems


I'm having a problem when I call the same Stripes action with multiple c:import tags in the same jsp. When I use the first c:import, I use a few c:params with it. These get bound to the corresponding fields in the action. But then when I use the next c:import, the fields are already set from the first c:import, which is not what I want. I want to be able to import an action several times, and each time it should only use the values I pass in with the c:param tags.

The only solution I could think of is to call a method before binding and validation takes place, that sets all the fields to null. Is that a bad idea? What's the best way to handle this?

    <c:import url="/widget/House.action">
        <c:param name="dogNam" value="Muffin" />
        <c:param name="catName" value="Junior" />
    </c:import>

    <c:import url="/widget/House.action">
        <c:param name="dogNam" value="Rocky" />
    </c:import>

In this example catName is getting set to "Junior" both the first and second time I use the c:import.


Solution

  • The c:import fires an http request to your Java application server and from what you describe the second c:import still seems to add the catName parameters to the request, you might want to try this:

    <c:import url="/widget/House.action">
        <c:param name="dogNam" value="Rocky" />
        <c:param name="catNam" value="" />
    </c:import>