myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Grant Smith <work.gr...@gmail.com>
Subject Re: h:commandButton won't call method
Date Wed, 16 Nov 2005 22:28:01 GMT
Joel,

you're removing the submit button from the form before the JSF phase that
calls the method on the backing bean executes.

I assume you're trying to circumvent the double submit problem. A better
approach would be to use a servlet filter to synchronize the requests.

On 11/16/05, Joel Wilson <joel@devotionmedia.com> wrote:
>
> I have an interesting problem where I have a basic form (just starting
> project so nothing fancy on the server side yet) that populates the values
> from the from into a map, and call a method which decides what form is next;
> absolutely basic and boring.
> What happens or doesn't and it somewhat confusing is that when the user
> clicks the next button, it simply returns to the page as if the method had
> returned null; but the method was never called; but if they click the
> commandLink it does get called. It is odd that one works and the other
> doesn't, and that is the basis of my confusion. I would assume it has
> something to do with MyFaces thinking that the form was submitted somehow
> other than via the commandButton component and therefore never puts into
> motion whatever calls the action method.
>
> Here is my faces-config.xml, the JSP I'm toying with, and what I have of
> my BackingBean class.
>
> THE JSP FILE
>
> <%@ page language="java" pageEncoding="UTF-8"%>
> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
> <%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
> <f:view>
> <f:loadBundle basename="com.devotion.gpn.subscription.bundles.subscription"
> var="subTerms" />
> <f:loadBundle basename="com.devotion.gpn.subscription.bundles.user" var="userTerms"
> />
> <f:loadBundle basename="com.devotion.gpn.subscription.bundles.commands"
> var="commandTerms" />
> <html>
>  <head>
>  <title>
>   My JSF 'beginsub.jspf' starting page
>  </title>
>
>  <meta http-equiv="pragma" content="no-cache">
>  <meta http-equiv="cache-control" content="no-cache">
>  <meta http-equiv="expires" content="0">
>  <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
>  <meta http-equiv="description" content="This is my page">
>
>  <script type="text/javascript" language="javascript">
>
>
>  var submit = true;
>
>
>  function removeButton() {
>   var elementHolder = document.getElementById("submitButton");
>   elementHolder.innerHTML = "${commandTerms.processing}";
>   submit = false;
>   return true;
>  }
>
>
>  </script>
>  <link href="https://www.gpn.tv/css/global.css" rel="stylesheet" type="text/css"
> />
>  <style type="text/css">
> body {
> margin-left: 0px;
> margin-top: 0px;
> margin-right: 0px;
> margin-bottom: 0px;
> background-color: #E1E1E1;
> background-image: url(../images/header/backgroung_internal_nt.jpg) repeat:
> repeat-x;
> font-family: Verdana, Arial, sans-serif;
> font-size: x-small;
> }
> div.register {
> border: 1px solid #CCCCCC;
> padding: 10px;
> background-color: #eeeeee;
> }
> div.register table tr td {
> border-bottom-width: 1px;
> border-bottom-style: solid;
> border-bottom-color: #CCCCCC;
> }
>
> div.register table tr td input {
> font-family: Verdana, Arial, Helvetica, sans-serif;
> color: #666666;
> border: 1px solid #999999;
> font-size: 11px;
> }
> div.register table tr td select {
> font-family: Verdana, Arial, Helvetica, sans-serif;
> border: 1px solid #999999;
> font-size: 11px;
> color: #666666;
> }
>
> div.register table tr td strong {
> color: #CC3333;
> }
>
> .required {
> color: #CC3333;
> }
>  </style>
>  </head>
>
>  <body>
>  <h:form id="form1" onsubmit="return removeButton();">
>   <div class="register">
>   <h:messages globalOnly="true" />
>   <table cellpadding="5" cellspacing="0" class="register">
>    <!--� Membership Type -->
>    <tr>
>    <td valign="top">
>     <h:outputLabel id="membershipTypeLabel" value="#{
> subTerms.subscriptionType}" for="membershipType" />
>    </td>
>    <td>
>     <h:selectOneMenu id="membershipType" value="#{
> createSubBean.subData.subscriptionType}">
>     <f:selectItem itemValue="familySub" itemLabel="#{
> subTerms.familySubscription}" />
>     <%/*<f:selectItem itemValue="groupSub" itemLabel="#{
> subTerms.groupSubscription}" />
>     <f:selectItem itemValue="sponsoredSub" itemLabel="#{
> subTerms.sponsoredSubscription}" />*/%>
>     </h:selectOneMenu>
>    </td>
>    </tr>
>
>    <!--� email -->
>    <tr>
>    <td>
>     <h:outputLabel id="emailLabel" value="#{userTerms.email}" for="email"
> />
>    </td>
>    <td>
>     <h:inputText id="email" value="#{createSubBean.subData.mainEmail}"
> required="true">
>     <t:validateEmail />
>     </h:inputText><br/>
>     <span class="errorMessage"><h:message id="emailMessage" for="email"
> /></span>
>    </td>
>    </tr>
>
>
> ...
>
> [Message clipped]
>



--
Grant Smith
Mime
View raw message