Yesterday I posted a question about having to press a button twice to get it to work. I received good help, which is the hallmark of stackoverflow, but the problem still exists. I cut down my code to the bare minimum and the problem still exists. I read closely a BalusC suggestion, hoping that I would find a form inside a form. There is certainly nothing I can see so I will post my code in the hopes that additional pairs of eyes will see something.
I have a template which I call from welcome (the login part). This goes to userInfo which has a command button. This is the command button which I mysteriously have to press twice. On the second push the command button will take me to userPhoto. Everything is trimmed down to the minimum so that I can post it.
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>
And last but not least userInfo.xhtml with the button which needs to be pressed twice:
<?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>
I don't see any form nested inside any other form, but SOMETHING is wrong and I can't figure out what. Maybe BalusC is correct that it has something to do with ajax, but I don't see that either.
Thanks for all the help.
Ilan
I added a button on the userPhoto page which goes back to the userInfo page. The Login button is the only one which works one the first press. When I use the command buttons to switch back and forth between userInfo and userPhoto, it always takes 2 pushes. I will show the center of 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>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…