2013-07-18 65 views
1

我想要跨應用程序獲取所有Ext.MessageBox.alert()並將其設置爲新位置。 我們在我們的應用程序中有很多jsp頁面,其中我們使用了Ext.MessageBox.alert(),現在需要重新定位所有的消息框,而不用在jsp中觸摸它們的代碼..我可以包含一個js文件,儘管Repostion Ext.MessageBox.alert()而不更改當前代碼

選項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); 
              } 

             }); 
+0

到選項1中的stackoverflow問題的鏈接指向無效。 – Christoph

回答

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 ALL()的調用。我不想在我的代碼中有這樣的黑客攻擊。

相關問題