如何将dijit.Dialog显示为弹出窗口

时间:2014-09-01 09:22:52

标签: java dojo dialog popupwindow

我正在尝试将dijit.Dialog显示为弹出窗口。这是现有项目的一个新功能,因为我从来没有用过Dojo;在我挣扎之前。 我创建了弹出窗口,但它一直显示为单独的页面而不是弹出窗口,我做错了什么?请帮忙!

显示弹出窗口按钮的页面

<input class="style_off pink_button ft_white" onclick='submitOnclick()'  id="show_popup" type="submit" name="showPopup" value="Generate PopUp"/>
<span id="validationPopUp" style="display:none;"><c:out value=""/></span>

脚本页面:

function submitOnclick() {

        dojo.xhrPost({
              url: "${get_valpopup_url}",                
              form: dojo.byId("searchResults"),
              load: function(data){
                //Destroy widget to avoid reallocating it during parse.                 

                if(valDialog) {
                    valDialog.destroy();
                } 
                dojo.place(data, "validationPopUp", "only");
                dojo.parser.parse("validationPopUp");
                valDialog = dijit.byId('inputPopUpId');
                valDialog.show();
               },
               error: function(e) {
                  console.log("Ajax call failed", e);
               }
         });

        return false;
    }

弹出窗口

<?xml version="1.0" encoding="UTF-8"?>
<div id="inputPopUpId" dojotype="dijit.Dialog" title="${popup_title}" 
    height="500px;" xmlns:f="http://www.twister.total.com/taglib"
    xmlns:fn="http://java.sun.com/jsp/jstl/functions"
    xmlns:fmt="http://java.sun.com/jsp/jstl/fmt"
    xmlns:tiles="http://tiles.apache.org/tags-tiles"
    xmlns:c="http://java.sun.com/jsp/jstl/core"
    xmlns:util="urn:jsptagdir:/WEB-INF/tags/util"
    xmlns:form="http://www.springframework.org/tags/form"
    xmlns:jsp="http://java.sun.com/JSP/Page"
    xmlns:s="http://www.twister.total.com/taglib/sessionAttr"
    xmlns:spring="http://www.springframework.org/tags" version="2.0">
    <jsp:directive.page contentType="text/html;charset=UTF-8" />
    <jsp:output omit-xml-declaration="yes" />

    <spring:message code="random_extract_popup_title" var="popup_title" htmlEscape="false" />
    <p>
        <spring:message code="random_extract_popup_message" />
     </p>


     <form:form method="post" modelAttribute="inputPopup" action="reports" enctype="application/x-www-form-urlencoded">
                <s:insertSessionConversationId attributeName="searchResults"/>
                        <s:insertSessionConversationId attributeName="searchDto"/>
      <div>
        <label for="noOfRecords">
          <spring:message code="random_extract_popup_form_label" />
        </label>
        <input id="noOfRecords" type='text' name='noOfRecords' style="width:150px" />
        <spring:message code="random_extract_popup_form_message" var="name_msg" htmlEscape="false" />
        <script type="text/javascript">
          <c:set var="sec_name_msg">
            <spring:escapeBody javaScriptEscape="true">${name_msg}</spring:escapeBody>
          </c:set>
          Spring.addDecoration(new Spring.ElementDecoration({elementId : "noOfRecords", widgetType : "dijit.form.NumberTextBox", widgetAttrs : {promptMessage: "${sec_name_msg}", required : true, constraints: {pattern: "0, ####"}}})); 
        </script>
      </div>

      <br />     
      <br />

      <div class="submit">        
        <spring:message code="button_extract_random_report" var="extract_random_report" htmlEscape="false" />
                    <script type="text/javascript">Spring.addDecoration(new Spring.ValidateAllDecoration({elementId:'extract_random_report', event:'onclick'}));</script>
                    <input class="startLoading style_off pink_button ft_white" id="extract_random_report" type="submit" name="extractrandom" value="${fn:escapeXml(extract_random_report)}"/>


      </div>
     </form:form> 
</div>

views.xml

<definition extends="empty" name="a/s/validationPopUpId">
        <put-attribute name="body" value="validation-dialog.jspx"/>
    </definition>

控制器中的代码

@RequestMapping(value = "sox/search/reports", params="showPopup", method = RequestMethod.POST)
   public String generatePopup(@ModelAttribute(TwisterConstants.SEARCH_RESULTS) AuditSoxListResultsDto searchResults, @ModelAttribute(TwisterConstants.SEARCH_DTO) AuditSoxSearchRequest searchDto, 
           Model uiModel, Locale selectedLocale, HttpServletRequest request, HttpServletResponse response){


      uiModel.addAttribute(TwisterConstants.SEARCH_RESULTS, TwisterConstants.SEARCH_DTO);

      addDateTimeFormatPatterns(uiModel,"S-");

      return "a/s/validationPopUpId";
   }

0 个答案:

没有答案