昨天我发布了一个关于不得不按两次按钮才能使其工作的问题。我收到了很好的帮助,这是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