2017-03-07 51 views
0

我使用的是JSF 2.0,我在home.xhml的div部分中有一個commandButton。它不工作。我沒有看到destinationPage,只留在home.xhtml中。h:commandButton的動作沒有被調用

home.xhmtl:

<div id="left_side"> 
    <ui:include src="login.xhtml" /> 
     <h:form> 
      <h:commandButton value="register" action="register"/> 
     </h:form> 
</div> 

register.xhtml是裏面啊:主體和啊:形式

和麪-config.xml配置:

<navigation-rule> 
    <from-view-id>home.xhtml</from-view-id> 
    <navigation-case> 
     <from-outcome>register</from-outcome> 
     <to-view-id>register.xhtml</to-view-id> 
    </navigation-case> 
</navigation-rule> 

回答

0

如果home.xhtmlregister.xhtml是應用程序的根源,那麼您需要按如下方式定義導航規則:

<navigation-rule> 
    <from-view-id>/home.xhtml</from-view-id> 
    <navigation-case> 
     <from-outcome>register</from-outcome> 
     <to-view-id>/register.xhtml</to-view-id> 
    </navigation-case> 
</navigation-rule> 

否則,你添加相對路徑的根..這將由反彈來表示

更新

其實你的情況看來,你真的不需要POST請求其由commandButton生成。一個簡單的按鈕,這將產生一個GET請求似乎是足夠的:

<h:button outcome="register" value="register" /> 
+0

乳清是在web應用(根)/模板..所以,我已經添加:<從視點-ID> /模板/家庭。 xhtml /templates/register.xhtml ..事情沒有好轉.. – Nica

+0

嘗試我的更新回答 –

+0

done ..現在它寫在註冊按鈕上:禁用,因爲導航case無法匹配... faces-config配置有問題?爲什麼這樣 ? – Nica