2013-02-15 2 views
0

하나의 Facelets 페이지에 h:commandLink이 하나 있습니다.FacesContext가 처음으로 컨텍스트 값을 잃어 버림

<h:commandLink value="#{View} &#187;" 
    onclick="return myJavaScript('#{myBean.param1}');"> 
</h:commandLink> 

function myJavaScript(paramReceived) 
{ 
    var relPath = "/myWarName/Pages/myReceiptPage.jsf?" 
        + myActionValue; 
    billWindow = window.open(relPath, '', 'width=' + width + ',height=' 
        + height + ',top=' + top + ',left=' + left 
        + ',scrollbars=1,resizable=1'); 
    billWindow.focus(); 
} 

다음은

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<div xmlns="http://www.w3.org/1999/xhtml" 
    xmlns:h="http://java.sun.com/jsf/html" 
    xmlns:ui="http://java.sun.com/jsf/facelets" 
    xmlns:f="http://java.sun.com/jsf/core"> 
    <head> 
    </head> 
     <f:view> 
      <body> 
      <h:form> 
       <ui:insert> 
          <ui:include src="/someOtherPage.xhtml" /> 
       </ui:insert> 

       <h:outputText value="#{facesContext.externalContext.requestParameterMap.UserID}" /> 

          </h:form> 
        <body> 
      </f:view> 
     <div> 

내가 h:commandLink 클릭

는 자바 스크립트 호출 및 도착, 내 myReceiptPage.xhtml 페이지 코드 창을 엽니하지만, 아래 예외 만에 처음합니다. 두 번째 이후부터 다시 h:commandLink을 클릭하면 예외없이 윈도우가 열리고 데이터가 제대로 채워집니다.

클릭하면 h:commandLink PhaseListener가 호출되어 하나의 메소드를 호출합니다. 다음은

javax.faces.FacesException: javax.el.ELException: /view.xhtml @192,150 userID="#{myBean.userID}": Error reading 'userID' on type com.myBean 
     at javax.faces.component.UIOutput.getValue(UIOutput.java:187) 
     at org.richfaces.component.UITabPanel.getValue(UITabPanel.java:103) 
     at org.richfaces.renderkit.TabPanelRendererBase.encodeTabs(TabPanelRendererBase.java:309) 
     at org.richfaces.renderkit.html.TabPanelRenderer.doEncodeBegin(TabPanelRenderer.java:228) 
     at org.richfaces.renderkit.html.TabPanelRenderer.doEncodeBegin(TabPanelRenderer.java:180) 
     at org.ajax4jsf.renderkit.RendererBase.encodeBegin(RendererBase.java:100) 
     at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:813) 
     at javax.faces.component.UIComponent.encodeAll(UIComponent.java:928) 
     at javax.faces.render.Renderer.encodeChildren(Renderer.java:148) 
     at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837) 
     at javax.faces.component.UIComponent.encodeAll(UIComponent.java:930) 
     at javax.faces.component.UIComponent.encodeAll(UIComponent.java:933) 
     at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592) 
     at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:189) 
     at org.jboss.portletbridge.application.PortletViewHandler.renderView(PortletViewHandler.java:247) 
     at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100) 

이 가능 원인이 무엇을 할 수 아래
public void getUserId() 
    { 
     try 
     { 
      FacesContext context = FacesContext.getCurrentInstance(); 
      ExternalContext externalContext = context.getExternalContext(); 
        //Code continues 
     } 
      Catch(Exception E) 
      { 
       //Am getting to know the exception here 
      } 
     } 

은 (창에 표시됩니다)의 예외입니다 코드인가?

편집 : 내용물은 view.xhtml입니다.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" 
    xmlns:h="http://java.sun.com/jsf/html" 
    xmlns:ui="http://java.sun.com/jsf/facelets" 
    xmlns:f="http://java.sun.com/jsf/core" 
    xmlns:a4j="http://richfaces.org/a4j" 
    xmlns:rich="http://richfaces.org/rich" 
    xmlns:t="http://myfaces.apache.org/tomahawk"> 
<head> 
</head> 
<h:form id="myFormId"> 
<ui:insert> 
    <ui:include src="/myWarName/Pages/someOtherPage.xhtml" /> //Guess, problem is with this include. 
//This include is also there in myReceiptPage.xhtml page. 
</ui:insert> 

<rich:tabPanel selectedTab="#{myBean.getSelectedTab}"> 
    <rich:tab name="Tab Name"> 
     <h:panelGroup> 
      <ui:insert> 
       <ui:include src="somePage1.xhtml" /> 
      </ui:insert> 
     </h:panelGroup> 
     <h:panelGroup> 
      <ui:insert> 
       <ui:include src="somePage2.xhtml" /> 
      </ui:insert> 
     </h:panelGroup> 
</rich:tab> 
</h:form 
</html> 

는 예외 목록에 추가하려면, <rich:tabPanel selectedTab="#{someBean.getSelectedTab}">

getSelectedTab 방법은 위의 다음과 같습니다

public class myBean implements Serializable{ 
public String getSelectedSubTab() 
{ 
    FacesContext con=FacesContext.getCurrentInstance(); 
    ExternalContext externalContext = con.getExternalContext(); 
    String remoteUserId = externalContext.getRemoteUser(); 
    User user = UserServiceUtil.getUserById(Long.parseLong(remoteUserId)); 
    this.userID = user.getScreenName();   
} 
} 
+1

전체 스택 추적입니까? EL 초크를 만드는 근본적인 원인이있는 것처럼 보입니다. – kolossus

+0

글쎄, 여기서'view.xhtml'을 보지 못했고 여기에 문제가있는 EL이 있습니다. – partlov

+0

@kolossus 예외가 아닌 NullPointerException도 발생합니다. 그리고 이것은 내 질문에 업데이 트되었습니다. –

답변

0

나는 여전히 모든 XHTML 파일에 표현 #{myBean.userID}이 표시되지 않는 것을 말해야한다 , 문제는 아마도 getter 메소드 getUserId()void으로 선언되었으므로 여기서 userId 속성이 고려됩니다. 읽을 수 없다. getter에서 물건을 반환해야합니다.

관련 문제