You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@shale.apache.org by Dick Starr <di...@medibadge.com> on 2006/10/30 14:52:14 UTC

Why do I need to click my action method commandButton twice?

I am using the 10/4/06 version of Shale.
 
I have an h:form containing a h:panelGrid whose footer contains a
h:commandButton in its footer as follows:
 
<h:commandButton action="#{systemOperatorMnt.create}"
    id="mntButtonsCreate"
    value="Create"/>
 
I fill in the form and click the "Create" button and my form clears
without the "create" method being executed.
 
I fill in the form again (so I get past validation) and click the
"Create" button. This time the "create" method is executed.
 
I must be missing something. Could you please tell me:
 
Why is my form being cleared the first time I click "Create"?
 
Why do I need to click the "Create" button twice?
 
Thanks in advance,
 
Dick Starr
 
P.S. My form is included below.
 
<%-- operatorMnt.jsp
  2006-10-27 RJS. New.
--%>
<%@ include file="/jspf/common/taglibs.jsp" %>
<%@ include file="/jspf/common/messages.jsp" %>
 
<h:form id="operatorMnt">
      
  <h:panelGrid
    border="1"
    cellspacing="2"
    cellpadding="2"
    columns="2"
    footerClass="starraPanelGridFooter"
    headerClass="starraPanelGridHeader"
    styleClass="starraBody">
    
    <f:facet name="header">
      <h:outputText value="#{msg['class.SystemOperatorMnt']}"/>
    </f:facet>
    
    <h:outputLabel styleClass="starraReadonly">
      <h:outputText value="#{msg['app.Operator.id']}"/>
      <h:outputText value="#{msg['symbol.sep1']}"/>
    </h:outputLabel>
    <h:panelGroup>
      <h:inputText id="syOperatorId" readonly="true"
value="#{systemOperatorMnt.syOperatorId}"/>
    </h:panelGroup>
    
    <h:outputLabel for="name">
      <h:outputText  value="#{msg['app.Name']}"/>
      <h:outputText value="#{msg['symbol.sep1']}"/>
    </h:outputLabel>
    <h:panelGroup>
      <h:inputText id="name" maxlength="48" required="true" size="36"
value="#{systemOperatorMnt.name}">
        <f:validateLength minimum="4" maximum="48"/>
      </h:inputText>
      <h:message for="name" styleClass="starraMsgError"/>        
    </h:panelGroup>
      
    <h:outputLabel for="logonName">
      <h:outputText  value="#{msg['app.Logon.name']}"/>
      <h:outputText value="#{msg['symbol.sep1']}"/>
    </h:outputLabel>
    <h:panelGroup>
      <h:inputText id="logonName" maxlength="24" required="true"
size="24" value="#{systemOperatorMnt.logonName}">
        <f:validateLength minimum="4" maximum="24"/>
      </h:inputText>
      <h:message for="logonName" styleClass="starraMsgError"/>        
    </h:panelGroup>
 
    <h:outputLabel for="logonPassword">
      <h:outputText value="#{msg['app.Logon.password']}"/>
      <h:outputText value="#{msg['symbol.sep1']}"/>
    </h:outputLabel>
    <h:panelGroup>
      <h:inputText id="logonPassword" maxlength="24" required="true"
size="24" value="#{systemOperatorMnt.logonPassword}">
        <f:validateLength minimum="4" maximum="24"/>
      </h:inputText>
      <h:message for="logonPassword" styleClass="starraMsgError"/>
    </h:panelGroup>
    
    <h:outputLabel for="logonBegDate">
      <h:outputText value="#{msg['app.Logon.beg.date']}"/>
      <h:outputText value="#{msg['symbol.sep1']}"/>
    </h:outputLabel>
    <h:panelGroup>
      <h:inputText id="logonBegDate" required="true"
value="#{systemOperatorMnt.logonBegDate}">
        <f:convertDateTime dateStyle="short"/>
      </h:inputText>
      <h:message for="logonBegDate" styleClass="starraMsgError"/>
    </h:panelGroup>
    
    <h:outputLabel for="logonEndDate">
      <h:outputText value="#{msg['app.Logon.end.date']}"/>
      <h:outputText value="#{msg['symbol.sep1']}"/>
    </h:outputLabel>
    <h:panelGroup>
      <h:inputText id="logonEndDate" required="true"
value="#{systemOperatorMnt.logonEndDate}">
        <f:convertDateTime dateStyle="short"/>
      </h:inputText>
      <h:message for="logonEndDate" styleClass="starraMsgError"/>
    </h:panelGroup>
    
    <h:outputLabel styleClass="starraReadonly">
      <h:outputText value="#{msg['app.Row.operator.id']}"/>
      <h:outputText value="#{msg['symbol.sep1']}"/>
    </h:outputLabel>
    <h:panelGroup>
      <h:inputText readonly="true" size="6"
value="#{systemOperatorMnt.rowSyOperatorId}"/>
    </h:panelGroup>
    
    <h:outputLabel for="rowCreated" styleClass="starraReadonly">
      <h:outputText value="#{msg['app.Row.created']}"/>
      <h:outputText value="#{msg['symbol.sep1']}"/>
    </h:outputLabel>
    <h:panelGroup>
      <h:inputText id="rowCreated" readonly="true"
value="#{systemOperatorMnt.rowCreated}">
        <f:convertDateTime dateStyle="short" timeStyle="short"/>
      </h:inputText>
      <h:message for="rowCreated" styleClass="starraMsgError"/>
    </h:panelGroup>
    
    <h:outputLabel for="rowUpdated" styleClass="starraReadonly">
      <h:outputText value="#{msg['app.Row.updated']}"/>
      <h:outputText value="#{msg['symbol.sep1']}"/>
    </h:outputLabel>
    <h:panelGroup>
      <h:inputText id="rowUpdated" readonly="true"
value="#{systemOperatorMnt.rowUpdated}">
        <f:convertDateTime dateStyle="short" timeStyle="short"/>
      </h:inputText>
      <h:message for="rowUpdated" styleClass="starraMsgError"/>
    </h:panelGroup>
    
    <f:facet name="footer">
      <%@ include file="/jspf/common/mntButtons.jsp" %>
    </f:facet>      
      
  </h:panelGrid>
    
</h:form>
 
 

Re: Why do I need to click my action method commandButton twice?

Posted by Craig McClanahan <cr...@apache.org>.
On 10/30/06, Dick Starr <di...@medibadge.com> wrote:
>
> I am using the 10/4/06 version of Shale.
>
> I have an h:form containing a h:panelGrid whose footer contains a
> h:commandButton in its footer as follows:
>
> <h:commandButton action="#{systemOperatorMnt.create}"
>     id="mntButtonsCreate"
>     value="Create"/>
>
> I fill in the form and click the "Create" button and my form clears
> without the "create" method being executed.
>
> I fill in the form again (so I get past validation) and click the
> "Create" button. This time the "create" method is executed.
>
> I must be missing something. Could you please tell me:
>
> Why is my form being cleared the first time I click "Create"?
>
> Why do I need to click the "Create" button twice?


The most common cause for this type of scenario (generic to JSF apps, not
specific to Shale) is that some conversion or validation error occurred, but
you don't have message components to show them.  In that situation, JSF's
standard behavior is to abort the request processing lifecycle after the
phase in which the error is encountered -- which is usually Process
Validations.

In your case, you have <h:message> components for each input field ... but
what happens if an error occurs that is not associated with a particular
input component?  Try sticking an <h:messages/> component somewhere on the
page, to see if it lists any additional errors.


Thanks in advance,
>
> Dick Starr



Craig