Board index JavaServer Faces General p:commandButton only works after refresh

p:commandButton only works after refresh

Components, Ajax Framework, Utilities and More.


Posts: 44
Hello everybody,

I have the following commandButton which is presenting a wierd behavior. It only works after I completely refresh the page. This issue happens in any browser, and it happens ONLY in the first time I acess the page. I mean, after the refresh, I can even restart GlassFish v3, and the problem won't happen.

Does anyone one know what is happening here?

I am using JSF 2.0 and PrimeFaces 2.1 and the NewsletterBean is @ViewScoped

By the way... any p:commandButton in my application presents this behavior. I wonder if I am missunderstanding how pirmeFaces works.

<?xml version="1.0" encoding="UTF-8"?>
<!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:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:pretty="http://ocpsoft.com/prettyfaces">

<h:head>
   <link rel="SHORTCUT ICON" href="favicon.ico"/>
   <link type="text/css" rel="stylesheet" href="theme/start/skin.css" />
   <link href="style/template_style.css" type="text/css" rel="stylesheet" />
   
   <ui:insert name="load_style" />
   
   <title>title</title>
   
   <!-- ANALYTICS -->
   <script type="text/javascript">
     <!-- google analytics code -->
   </script>
</h:head>

<h:body>

<f:view>
   <div id="top_global">
      <div id="top">
         <ui:include src="/includes/top.xhtml" />
      </div>
   </div>
   
   <div id="menu">
      <p:panel id="newsletter_form_panel">
         <p:outputPanel id="output_nl">
         <h:form id="newsletter_form" prependId="false">
            <p:growl id="grow1" showDetail="true" />
            <h:panelGrid columns="4" style="float:left;">
               <h:outputLabel for="nl_mail" value="E-mail:" styleClass="email_label" />
               <h:inputText id="nl_mail" value="#{newsLetterBean.email}" required="true" requiredMessage="Informe seu e-mail!"
                   validator="emailValidator" />
               <h:selectOneMenu value="#{sessionsBean.currentCity}" converter="cityEntityConverter">
                  <f:selectItems value="#{newsLetterBean.allCities}"/>
               </h:selectOneMenu>   
               <p:commandButton id="save_nl_button2" actionListener="#{newsLetterBean.createNewsLetter}" value="Cadastrar E-mail!" update="output_nl" />
            </h:panelGrid>
            <span style="float:right; width:300px;">Cadastre-se agora para ficar por dentro das novidades!</span>
            <p:ajaxStatus style="float:right; margin:7px 40px 0 0;"> 
                <f:facet name="start">
                   <center> 
                       <h:graphicImage value="/images/ajax-loader.gif" /> 
                   </center>
                </f:facet> 
                  <div id="widget"></div>
                <f:facet name="complete"> 
                    <h:outputText value="" /> 
                </f:facet> 
            </p:ajaxStatus>
         </h:form>
         <br style="clear: both;" />
         </p:outputPanel>
      </p:panel>
   </div>
   
   <div id="content">
      <ui:insert name="content" />
   </div>
   
   <div id="footer_global">
      <div id="footer">
         <ui:include src="/includes/footer.xhtml" />
      </div>
   </div>
</f:view>

</h:body>
</html>
NetBeans 7.3, Glassfish 3.1.2, Java EE 7, PrimeFaces 3.5 , Mojarra 2.1.17

Return to General