2013-02-22 123 views
0

編輯:這發生在任何組件AJAX調用期間。ICEFaces AJAX重定向到404

我正在使用ICEFaces 3.2.0社區和Spring Security 3.2一起構建一個Web應用程序,直到幾天前一切都變得非常順利。我在頁面與連接到值如以下示例的背襯豆的ACE AutoCompleteEntry成分:

<ace:autoCompleteEntry id="autoCompleteState" 
        label="State" 
        labelPosition="top" 
        value="#{autoCompleteEntry.selectedText}" 
        rows="10" width="160" 
        filterMatchMode="startsWith"> 
    <f:selectItems value="#{autoCompleteEntry.states}"/> 
</ace:autoCompleteEntry> 

附背襯豆如下:

@ManagedBean(name=AutoCompleteEntry.BEAN_NAME) 
@SessionScoped 

public class AutoCompleteEntry implements Serializable { 
    public static final String BEAN_NAME = "autoCompleteEntry"; 

    public static final String STATE_FILENAME = "State_Names.txt"; 
    public static final String RESOURCE_PATH = "/resources/selectinputtext/"; 

    public AutoCompleteEntry() {   
    } 

    public List<SelectItem> states;  
    public List<SelectItem> getStates() { 
     if(states == null) { 
      states = new ArrayList<SelectItem>(); 
      for(String state : readStateFile()) { 
       states.add(new SelectItem(state)); 
      } 
     } 
     return states; 
    } 

    private String selectedText = null; 
    public String getSelectedText() {return selectedText;} 
    public void setSelectedText(String selectedText) {this.selectedText = selectedText;} 

    private static List<String> readStateFile() { 
     InputStream fileIn = null; 
     BufferedReader in = null; 

     try { 
      FacesContext fc = FacesContext.getCurrentInstance(); 
      ExternalContext ec = fc.getExternalContext(); 
      fileIn = ec.getResourceAsStream(AutoCompleteEntry.RESOURCE_PATH + STATE_FILENAME); 

      if(fileIn != null) { 
       in = new BufferedReader(new InputStreamReader(fileIn)); 
       List<String> loadedStates = new ArrayList<String>(53); 
       String read; 
       while((read = in.readLine()) != null) { 
        loadedStates.add(read); 
       } 

       return loadedStates; 
      } 
     }catch (IOException failedRead) { 
      failedRead.printStackTrace(); 
     }finally { 
      try { 
       if(in != null) { 
        in.close(); 
       } 
      }catch (IOException failedClose) { 
       failedClose.printStackTrace(); 
      } 
     } 

     List<String> errorReturn = new ArrayList<String>(1); 
     errorReturn.add("Error Loading State List"); 
     return errorReturn; 
    } 
} 

的問題是每個時間我試圖測試組件,而不是造就的國家名單它重定向到我的主要頁面的絕對路徑,這會導致404在開發工具的我看到的錯誤:

> Uncaught TypeError: Cannot read property 'value' of undefined 
bridge.uncompressed.js.jsf:2701 
namespace.onAfterUpdate.viewIDElement bridge.uncompressed.js.jsf:2701 
apply bridge.uncompressed.js.jsf:122 
(anonymous function) bridge.uncompressed.js.jsf:484 
(anonymous function) bridge.uncompressed.js.jsf:363 
(anonymous function) bridge.uncompressed.js.jsf:240 
broadcast bridge.uncompressed.js.jsf:483 
(anonymous function) bridge.uncompressed.js.jsf:1928 
sendEvent jsf.js.jsf:1447 
AjaxEngine.req.sendRequest jsf.js.jsf:1333 
request jsf.js.jsf:1834 
fullSubmit bridge.uncompressed.js.jsf:2309 
submit bridge.uncompressed.js.jsf:2314 
iceSubmit compat.uncompressed.js.jsf:1523 
onclick 

開發工具日誌顯示:

> [window] persisted focus for element "autoCompleteState_input" 
bridge.uncompressed.js.jsf:1252 
[window] full submit to localhost:8181/HHCA_Portal/pages/secure/HHCA.jsf 
javax.faces.execute: @all 
javax.faces.render: patientRecordsForm 
javax.faces.source: autoCompleteState_input 
view ID: v33tl98j 
event type: unknown bridge.uncompressed.js.jsf:1252 
XHR finished loading: "localhost:8181/HHCA_Portal/pages/secure/HHCA.jsf". 
jsf.js.jsf:1334 
AjaxEngine.req.sendRequest jsf.js.jsf:1334 
request jsf.js.jsf:1834 
fullSubmit bridge.uncompressed.js.jsf:2309 
ice.ace.AjaxRequest ace-jquery.uncompressed.js.jsf:20854 
ice.ace.ab ace-jquery.uncompressed.js.jsf:20779 
ice.ace.Autocompleter.getUpdatedChoices autocompleteentry.js.jsf:695 
ice.ace.Autocompleter.onObserverEvent autocompleteentry.js.jsf:637 
(anonymous function) 

我花了很多時間在這個問題和其他問題的工作,我已經江郎才盡。如果有人有某種幫助,我會非常感謝幫助。

回答

1

如果您使用的是JSF 2,那麼您可以添加自己的異常處理程序,這應該能夠捕獲ajax請求。

<factory> 
    <exception-handler-factory> 
    test.MyExceptionHandlerFactory 
    </exception-handler-factory> 
</factory> 

看到這裏的例子,

http://balusc.blogspot.com/2012/03/full-ajax-exception-handler.html

http://wmarkito.wordpress.com/2012/04/05/adding-global-exception-handling-using-jsf-2-x-exceptionhandler/

+0

謝謝你的提示,阿維納什。非常感激。 – Fred 2013-03-03 00:56:08