1

我想跨应用程序获取所有 Ext.MessageBox.alert() 并将其设置为新位置。我们的应用程序中有许多 jsp 页面,其中我们使用了 Ext.MessageBox.alert(),现在的要求是重新定位所有消息框,而不触及它们在 jsp 中的代码。虽然我可以包含一个 js 文件

选项 1:我发现我可以通过以下方式重新定位消息警报:https ://stackoverflow.com/questions/1...l-align-with-y 但是我必须更改所有 jsp 页面并添加:

msgBox=Ext.MessageBox.alert(jsonData.responseMessage);
msgBox.getPositionEl().setTop(50);

选项2:扩展消息框:仍然更改所有jsp

选项3:使用css:不知道怎么做?

如果有任何其他解决方案或Css解决方案可以,任何人都可以指导我:

我的代码如下

    Ext.Ajax.request({
                        url : 'submitAddZone.htm',
                        params : {
                                                zoneName : Ext.getCmp('zoneNameId').getValue(),
                                                emailParam : Ext.getCmp('emailId').getValue(),
                                                requestTypeParam : Ext.getCmp('requestTypeId').getValue(),
                                                level : selectedLevel + 1,
                                                parentZoneName : selectedParentZone,
                                                currency : currencyValue,
                                                startDate : Ext.getCmp('startDateId').getValue(),
                                                startTime : Ext.getCmp('startTimeId').getValue()
                                            },
                                            method : 'POST',

                                            success : function(response,request) {
                                                toggleAddZoneElements();

                                                       var jsonData = Ext.decode(response.responseText);
                                                       if(jsonData.isSuccess){
                                                       msgBox=   Ext.MessageBox.alert(jsonData.responseMessage);
                                                     msgBox.getPositionEl().setTop(50);

                                                       addZoneWin.close();
                                                       toggleAddZoneButtons();
                                                       tree.getStore().load({url: 'loadCustomerStructure.htm'});
                                                       }else{
                                                       Ext.getCmp('sendRequest').setIcon();
                                                       Ext.getCmp('errorMessage1').setText(Encoder.htmlDecode(jsonData.errorMessage));
                                                       Ext.getCmp('errorMessage1').show();
                                                       }
                                            },
                                            failure : function(
                                                    response) {
                                                toggleAddZoneElements();
                                                msgBox= Ext.MessageBox.alert(notCreatedLabel);
                                                addZoneWin.close();
                                                msgBox.getPositionEl().setTop(50);
                                            }

                                        });
4

1 回答 1

0

一个干净的解决方案是创建您自己的 MessageBox 类,该类提供自定义警报方法,您可以在其中调用 Ext.MessageBox.alert() 并更改位置。但这需要您更改所有 jsp 文件。

现在它变脏了:您可以尝试覆盖 Ext.MessageBox.alert:

Ext.override(Ext.MessageBox,{
    alert: function(message){
         var msgBox = Ext.MessageBox.alert(message);
         msgBox.getPositionEl().setTop(50);
    }
});

但这会影响对 Ext.MessageBox.alert() 的所有调用。我不想在我的代码中有这样的 hack。

于 2013-07-18T13:42:22.000 回答