昨天我發佈了一個關於不得不按兩次按鈕才能使其工作的問題。我收到了很好的幫助,這是stackoverflow的標誌,但問題仍然存在。我將代碼減少到最低限度,問題依然存在。我仔細閱讀了一條BalusC的建議,希望能在窗體中找到一個表單。我當然沒有什麼可以看到的,所以我會發布我的代碼,希望額外的雙眼會看到一些東西。繼續按下按鈕兩次
我有一個模板,我從歡迎(登錄部分)調用。這轉到具有命令按鈕的userInfo。這是我神祕地按下兩次的命令按鈕。在第二次按下命令按鈕將帶我到userPhoto。一切都縮減到最低限度,以便我可以發佈。
master.xthml:
<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<h:head>
<title>Master template</title>
</h:head>
<h:body>
<p:layout fullPage="true" >
<p:layoutUnit position="north" size="254">
Top
</p:layoutUnit>
<p:layoutUnit position="east" size="50" resizable="true">
Hello
</p:layoutUnit>
<p:layoutUnit position="south" size="30">
south
</p:layoutUnit>
<p:layoutUnit position="center">
<ui:insert name="AreaOne">Default text</ui:insert>
</p:layoutUnit>
</p:layout>
</h:body>
</html>
welcome1.xhtml:
<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<ui:composition template="master.xhtml">
<ui:define name="AreaOne">
<h:form id="form1">
<p:commandButton type="submit" value="Login" action="userInfo" />
</h:form>
<p:messages />
</ui:define>
</ui:composition>
</html>
最後但並非最不重要的userInfo.xhtml與需要被按壓兩次按鈕:
<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<ui:composition template="master.xhtml">
<ui:define name="AreaOne">
<h:form id="formP">
<p:commandButton type="submit" value="photos" action="userPhoto" />
</h:form>
<p:messages />
</ui:define>
</ui:composition>
</html>
我沒有看到任何形式嵌套在任何其他形式,但SOMETHING是錯誤的,我不知道什麼。也許BalusC是正確的,它與ajax有關,但我也沒有看到。
感謝您的幫助。 Ilan
我在userPhoto頁面上添加了一個按鈕,該按鈕返回到userInfo頁面。登錄按鈕是唯一一個第一次按下的按鈕。當我使用命令按鈕在userInfo和userPhoto之間來回切換時,它總是需要2次按下。我會顯示userPhoto的中心
<ui:composition template="master.xhtml">
<ui:define name="AreaOne">
<h:form id="form3">
<p:commandButton type="submit" value="home page" action="userInfo" />
</h:form>
<p:messages />
</ui:define>
</ui:composition>
說,如果您用'默認文本'' '(僅用於測試) 在展示中沒有看到他們在佈局中使用了'
Daniel
嗨,Daniel。這將使其自動遞歸調用。默認文本是這樣的,只要我不 –
就會出現SOMETHING。我的意思是說,你只留下了master.xhtml中的表單。 – Daniel