Please pardon this somewhat long post, but I want to be as detailed as
possible.  I've actually not had an opportunity to work with indexed
properties as maps before.  But let me back up a bit and give the scenario.
I'm having to build some ad hoc reporting functionality into an
application.   The domain objects were here long before I started working on
this application.  The client wants the ability to see a list of possible
search columns and do several things.

1.  There is a checkbox specifying that this col should be displayed in the
report
2.  There is a checkbox specifying that this col should be used as search
criteria but not shown in the results
3.  There are choices as to what what kind of criteria is used as in
Contains, Equals, etc.
4.  There is either a textfield for a search value or there is a list of
checkboxes of possible values to search on.

My first attempt at this worked ok for a while.  I have an object called
StoredReportItem which contains the column name to search on, the value of
the checkboxes mentioned above, etc.  I then created an object called
StoredReportItemValue which held the value(s) that were going to be used in
the search criteria.  StoredReportItem contained a List of these values.

Everything worked ok using indexed properties as Lists but here is the
problem.  Assuming one of the searchable cols has a list of checkboxes as
possible values.  Then assume any checkbox is selected other than the first
one.  When the search page is displayed for edit the correct checkbox is not
selected because since it was saved to the database and when pulled out it
comes out as the first in the List, the index is wrong.  So when it should
have been values[1] it comes back as values[0].

So my next thought was to use mapped indexed properties to help solve this.
This way, it wouldn't matter what the index was, but what the key is.
However, I'm having some problems translating what I have into what I need.
Below are my 2 current objects along wtih an example of how they are used in
the JSP.  I've ommitted some things for brevity.

public class StoredReportGlobalItem implements Serializable {

    private Integer id;
    private boolean displayOnReport;
    private boolean useNonDisplayedSearchCriteria;
    private boolean modifyAtRuntime;
    private String searchFilter;
    private StoredReport storedReport;
    private String queryProperty;
    private List<StoredReportGlobalItemValue> values;
}

public class StoredReportGlobalItemValue implements Serializable {

    private Integer id;
    private String value;
    private StoredReportGlobalItem globalItem;
}


<s:form id="reportForm"
beanclass="com.aga.dashboard.actions.stripes.AdHocReportingAction"
partial="true">
    <tr id="${param.reportIndex}">
        <td>Organizations</td>
        <c:choose>
            <c:when test="${param.modify == false}">
                <td><s:checkbox class="global_displayOnReport"

name="report.storedReportGlobalItems[${param.reportIndex}].displayOnReport"/></td>
                <td><s:checkbox class="global_useNonDisplayedSearchCriteria"

name="report.storedReportGlobalItems[${param.reportIndex}].useNonDisplayedSearchCriteria"/></td>
                <td><s:checkbox
name="report.storedReportGlobalItems[${param.reportIndex}].modifyAtRuntime"/></td>
            </c:when>
            <c:otherwise>
                <s:hidden
name="report.storedReportGlobalItems[${param.reportIndex}].displayOnReport"/>
            </c:otherwise>
        </c:choose>
        <td>
            Has Any Value
            <s:hidden
name="report.storedReportGlobalItems[${param.reportIndex}].searchFilter"
value="HAS_ANY_VALUE"/>
        </td>
        <td>
            <div style="background-color: white; overflow: auto; width:
200px; height: 100px">
                <c:forEach var="org" items="${actionBean.orgs}"
varStatus="status">
                    <s:checkbox value="${org.id}"

name="report.storedReportGlobalItems[14].values[${status.index}].value"/>${
org.name}
                    <br/>
                </c:forEach>
            </div>
            <s:hidden
name="report.storedReportGlobalItems[${param.reportIndex}].queryProperty"
                      value="organization.id"/>
            <s:hidden
name="report.storedReportGlobalItems[${param.reportIndex}].id"/>
            <c:forEach var="value"
items="${actionBean.report.storedReportGlobalItems[param.reportIndex].values}"
                       varStatus="status">
                <s:hidden
name="report.storedReportGlobalItems[${param.reportIndex}].values[${status.index}].id"/>
            </c:forEach>
        </td>
    </tr>
</s:form>

I know the JSP looks somewhat confusing but if you ignore all the choose
whens it makes more sense.  I had to do some of that so the JSP could be
resused a bit more.

So I'm looking at how I might be able to translate my
StoredReportGloablItemValue to a Map that is used and how I might specify
the appropriate key/values in the JSP.  Again, sorry for the long post but I
wanted to be as clear as possible.

Gregg
------------------------------------------------------------------------------
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to