以编程方式关闭Liferay对话框

时间:2013-06-24 15:12:16

标签: javascript dialog liferay-6

我有Liferay对话框,我想关闭此对话框并希望将我的网址重定向到某个页面。

我这样做。

<aui:column columnWidth="16" >

<%if(UserGroupRoleLocalServiceUtil.hasUserGroupRole(u.getUserId(), groupId, role.getRoleId())){ %>

<input value="delete" type="button"  onclick="document.location.href='
<portlet:actionURL name="deleteUserRole"><portlet:param name="memberId" value="<%= memberIdStr %>"/>
<portlet:param name="organization" value="<%=  Long.toString(organizationID) %>"/></portlet:actionURL>'"  />
    <%} %>
            </aui:column>


public void deleteUserRole(ActionRequest actionRequest,ActionResponse actionResponse){

// process to delete user role

    Role r = RoleLocalServiceUtil.getRole(org.getCompanyId(),
                    "Power User");


    UserGroupRoleLocalServiceUtil.deleteUserGroupRoles(userID, groupId, new long[] { r.getRoleId() });

        actionResponse.sendRedirect("/group/employee/empHome");                 


}

通过这种方式,当我点击删除按钮时,这个方法会调用,执行进程,它会重定向到这个URL,但是会弹出窗口。

我想在actionResponse.sendRedirect页面中重定向到给定页面但不在对话框中,它不应该在dailog框中打开。

如何先关闭此对话框,然后将我的页面重定向到给定的网址?

我通过在链接上调用此类来打开对话框 下面是我的js文件

/ test.js /

 var myPopup;
AUI().ready( function() {

    if (AUI().one('#testing-menu')) {

    AUI().one('.extendClick').on(
        'mouseenter',
        function(event){
            AUI().one('.navi-type').setStyles({'display': 'none'});
            AUI().one('.extendClick').setStyles({'display': 'none'});
            AUI().one('.collapseArrow').setStyles({'display': 'block'});
        }
      );


   AUI().all('.employee-dialog').on(
        'click',
        function(event){
          var url = event.currentTarget.get('href');
          event.preventDefault();
          //console.info(url);

        window.myPopup= Liferay.Util.openWindow(
              {
                dialog: {
                  align: { points: ['tc', 'tc'] },
                  width: 960
                },
                title: 'Settings',
                uri: url
              }
            );
        }
      );


  }
});

2 个答案:

答案 0 :(得分:2)

保存弹出式引用,然后使用它来关闭弹出窗口:

var myPopup;
AUI().all('.employee-dialog').on(
    'click',
    function(event){
      [..]
      myPopup = Liferay.Util.openWindow([...]);
    }
  );

使用onclick中保存的弹出式参考:

<input value="delete" type="button" onclick="myPopup.close();document.location.href='
    [...]

答案 1 :(得分:0)

最后,我能够以这种方式关闭此对话框。

<input value="delete" type="button"  onclick="javascript:closePopUp;document.location.href='
<portlet:actionURL name="deleteUserRole"><portlet:param name="memberId" value="<%= memberIdStr %>"/>
<portlet:param name="organization" value="<%=  Long.toString(organizationID) %>"/></portlet:actionURL>'"  />





<script type="text/javascript">
function closePopUp(){
top.document.getElementById('closethick').click();
}
</script>
相关问题