2014-03-06 1 views
0

loginRegisterTemplate.xhtml이라는 페이스 렛 템플릿을 만들었습니다. 내가 템플릿 클라이언트에서 그것을 사용할 때, 그 안에 배치하면 관리 빈의 메소드가 호출되지 않습니다. 템플릿이 없으면 버튼이 잘 작동합니다. 왜 이런 일이 일어나는 걸까요?<h : commandButton> 내부에서 작동하지 않습니다 <ui:define>

옆의 간단한 <h:button>
<ui:composition template="resources/css/faceletsTemplates/loginRegisterTemplate.xhtml"> 
     <ui:define name="top"> 
      Login Page 
     </ui:define> 
     <ui:define name="content"> 
      <div align="center"> 
       <h:panelGrid columns="3" columnClasses="rightalign,leftalign,leftalign"> 

        <h:outputLabel value="Username:" for="userName"/> 
        <h:inputText id="userName" label="Username" required="true" value="#{loginBean.userName}" /> 
        <h:message for="userName" /> 

        <h:outputLabel value="Password:" for="password"/> 
        <h:inputText id="password" label="Password" required="true" value="#{loginBean.password}" /> 
        <h:message for="password" /> 
       </h:panelGrid><br/> 

       <h:button value="Back to Home" outcome="home"/> 
       <h:commandButton id="login" value="Login" action="#{loginBean.doLogin}"/> 
      </div> 
     </ui:define> 
    </ui:composition> 
</h:body> 

, 다른 측면에서, 정상적으로 작동된다. 여기 보았다

<h:body> 
    <div id="top"> 
     <ui:insert name="top">Top</ui:insert> 
    </div> 
    <div id="content" class="center_content"> 
     <ui:insert name="content">Content</ui:insert> 
    </div> 
</h:body> 

: 여기

내 템플릿 파일의 몸 h:commandLink/h:commandButton is not being invoked 그러나 나는 그 원인이되는 문제를 찾을 수 없습니다.

감사합니다.

답변

0

h:commandButton이 작동하지 않는 이유는 무엇입니까?

문제는 answer you have checked에서 1입니다.

UICommand 및 UIInput 성분은 UIForm 성분, 예를 들어 내부에 배치해야 <h:form>.

그럼 h:button은 왜 작동합니까? h:button docs에서

:

유형 "버튼"의 HTML "입력"요소를 렌더링. 구성 요소의 값은 버튼 텍스트로 렌더링되고 구성 요소의 결과는 onclick으로 활성화되는 대상 URL을 결정하는 데 사용됩니다. 그래서

...

JSF는 onclick 행사에서 실행됩니다 자바 스크립트 함수에 h:buttonoutcome 값을 넣어 것입니다. 그러나 POST 메서드를 사용하여 양식 제출시 h:commandButtonaction을 실행하므로 제출할 양식이 있어야합니다.

+0

감사합니다. 나는 그것을 어떻게 놓쳤는 지 정말로 모른다. 그리고 나는 더 복잡한 해결책을 찾는데 몰두했다. – BrainArchitect

관련 문제