当前位置: 代码迷 >> Java Web开发 >> 一个关于jsf中<h:commandLink>标签的有关问题
  详细解决方案

一个关于jsf中<h:commandLink>标签的有关问题

热度:607   发布时间:2016-04-17 13:03:29.0
一个关于jsf中<h:commandLink>标签的问题?
问题1:当一个链接未指定跳转地址时,他就随机变成前面的链接地址,这是为什么呢?具体请看header.jsp的 "Go! "链接。
问题2:当才启动服务器后链接要点击2次才有效,链接后也要后退2次才可以回到原来页面,这是为什么呢?具体请看header.jsp中的链接。
header.jsp:
<f:view>
<h:form>
<h:panelGrid   columns= "3 ">
<h:panelGrid   id= "header "   columns= "9 ">
<h:outputText   value= "ProjectTrack: "/>
<h:commandLink   action= "inbox ">
<h:graphicImage   url= "images/inbox.gif "   alt= "inbox "/>
<h:outputText   value= "inbox "/>
</h:commandLink>
<h:commandLink   action= "show_all ">
<h:graphicImage   url= "images/show_all.gif "   alt= "Show   all   projects "/>
<h:outputText   value= "Show   all "/>
</h:commandLink>
<h:commandLink   action= "create ">
<h:graphicImage   url= "images/create.gif "
styleClass= "header-icon "
alt= "Create   a   new   project "/>
<h:outputText   value= "Create   new "   styleClass= "header-command "/>
</h:commandLink>

<h:commandLink   action= "logout ">
<h:graphicImage   url= "images/logout.gif "
styleClass= "header-icon "
alt= "Logout "/>
<h:outputText   value= "Logout "   styleClass= "header-command "/>
</h:commandLink>
</h:panelGrid>

<h:panelGroup>
<h:outputLabel   for= "languageSelect ">
<h:outputText   value= "Langage: "/>
</h:outputLabel>
<h:selectOneListbox
id= "languageSelect "
size= "1 ">
<f:selectItem   itemLabel= "English "
    itemValue= "English "/>
<f:selectItem   itemLabel= "Russian "
    itemValue= "Russian "/>
</h:selectOneListbox>
<h:commandButton   value= "Go! "/>
</h:panelGroup>
<h:outputText   value= "proj_mgr "/>
</h:panelGrid>
</h:form>
</f:view>

faces-config.xml:
<faces-config>
<navigation-rule>
<from-view-id> /* </from-view-id>
<navigation-case>
<from-outcome> inbox </from-outcome>
<to-view-id> /inbox.jsp </to-view-id>
</navigation-case>
<navigation-case>
<from-outcome> show_all </from-outcome>
<to-view-id> /show_all.jsp </to-view-id>
</navigation-case>
<navigation-case>
<from-outcome> create </from-outcome>
<to-view-id> /create.jsp </to-view-id>
</navigation-case>
<navigation-case>
<from-outcome> logout </from-outcome>
<to-view-id> /logout.jsp </to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>

------解决方案--------------------
<h:commandButton value= "Go! " onclick= "return false; "/>