tags:

views:

19

answers:

0

I have a somewhat complicated issue.

I have a grid defined (using the Struts2-JQuery Grid Plugin). One of the columns has a custom formatter that calls a Javascript function to put a button into that column. (Note: I absolutely HATE doing it that way).

The point of the button is to open up a dialog box. This dialog box contains a checkboxlist, which can't be rendered in the grid.

Somehow, I need to pass a parameter to the action that returns the view that will be displayed inside the dialog.

Since this is somewhat complex, here is the code:

Grid definition:

<sjg:grid gridModel="gridModel"
          id="gridTable"
          caption="Manage Users"
          dataType="json"
          href="%{remoteUrl}"
          pager="true"
          rowList="10,15,20"
          rowNum="15"
          rownumbers="true"
          cellEdit="true"
          cellurl="%{editCell}"
        />
    <sjg:gridColumn name="id"
                    hidden="false"
                    title="id"
                    formatter="integer"
                    index="id"
                    key="true"
    />
    <!-- Other columns ommitted -->
    <sjg:gridColumn name="manageRoles"
                    title="Manage Roles"
                    sortable="false"
                    align="center"
                    formatter="formatRoles"
            />
</sjg:grid>

Javascript Custom Formatter:

    function formatRoles(cellValue, options, rowObject) {
        return "<button onClick='openRoleDialog(" + rowObject.id + ")'>Edit Roles</button>";
    }

Dialog Definition:

<s:url id="manageRoleUrl" action="viewRoles" namespace="userManagement" />
<sj:dialog id="manageRoles" title="Manage Roles" autoOpen="false" modal="true" href="%{manageRoleUrl}" resizable="true"/>

Remote Manage Roles JSP (trimmed):

    <s:form id="roleChoiceForm" action="/userManagement/editUserRole">
        <s:hidden id="id" name="id" />
        <s:checkboxlist list="roleChoices" name="selectedNameChoices" />
    </s:form>

Since I get the id of the grid object via javascript, but use the JSP taglib for the dialog, how can I pass the id around?