سؤال

I am using struts2-jquery Dialog Widget to open a JSP page, which has a form to edit the Category.

Category contains two fields associated with it; name, and description.

I want to pass a categoryId to the JSP page so the form will prepopulate through remoteurl.

<s:url id="cat1" var="remoteurl" action="editCategoryWindow"/>
<sj:dialog id="editCategoryDialog"
           autoOpen="false"
           height="auto"
           width="auto"
           modal="true"
           href="%{remoteurl}"
           title="Edit Category"/>
function editCategory(categoryId) {
    $('#cat1').attr('categoryId');
    $('#editCategoryDialog').dialog({
        autoOpen: false,
        modal: true,
        height: 500,
        width: 900
    });
    $('#editCategoryDialog').empty().data('categoryId', categoryId).dialog("open");
}

This doesn't work: there's a null pointer exception because there's no categoryId on the JSP page.

How should I pass the parameter to the JSP page?

هل كانت مفيدة؟

المحلول

Build the URL with the category:

<s:url id="cat1" var="remoteurl" action="editCategoryWindow">
  <s:param name="categoryId" value="%{whatever}"/>
</s:url>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top