Uploaded image for project: 'RichFaces'
  1. RichFaces
  2. RF-12003

Including h:head breaks f:ajax events of commandButton

    Details

      Description

      If I add h:head-Tag to my page, the ajax events of the h:commandButton are not working. The example should show up a panel with a click on a button, but nothing happens. The example is working when h:head is removed. I use a ConversationScoped Bean.

      <?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">
      
      <h: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:fn="http://java.sun.com/jsp/jstl/functions"
      	xmlns:a4j="http://richfaces.org/a4j"
      	xmlns:rich="http://richfaces.org/rich">
      
      <h:head>
      	<title>Test</title>
      </h:head>
      
      <f:metadata>
      	<f:event type="preRenderView"
      		listener="#{testController.beginConversation}" />
      </f:metadata>
      
      <h:body>
      	<f:view>
      		<h:form>
      			<h:commandButton value="showField"
      				action="#{testController.changeRenderInputPanel}">
      				<f:ajax event="click" render="inputPanelId" execute="@form" />
      			</h:commandButton>
      
      			<h:panelGroup id="inputPanelId" layout="block"
      				rendered="#{testController.renderInputPanel}">
      				<h:outputText value="Author" />
      				<h:inputText value="#{testController.newCommentAuthor}" />
      			</h:panelGroup>
      		</h:form>
      	</f:view>
      </h:body>
      </h:html>
      
      import java.io.Serializable;
      
      import javax.enterprise.context.Conversation;
      import javax.enterprise.context.ConversationScoped;
      import javax.inject.Inject;
      import javax.inject.Named;
      
      import org.apache.commons.logging.Log;
      
      @Named
      @ConversationScoped
      public class TestController implements Serializable{
      
      	private static final long serialVersionUID = 1L;
      	
      	@Inject
      	private Conversation conversation;
      	
      	private String newCommentAuthor;
      	
      	private boolean renderInputPanel = true;
      	
      	@Inject
      	private Log logger;
      	
      	public boolean isRenderInputPanel() {
      		return renderInputPanel;
      	}
      
      	public void setRenderInputPanel(boolean renderInputPanel) {
      		this.renderInputPanel = renderInputPanel;
      	}
      	
      	public void changeRenderInputPanel() {
      		this.setRenderInputPanel(!isRenderInputPanel());
      		logger.info("render panel: " + renderInputPanel);
      	}
      
      	public String getNewCommentAuthor() {
      		return newCommentAuthor;
      	}
      
      	public void setNewCommentAuthor(String newCommentAuthor) {
      		this.newCommentAuthor = newCommentAuthor;
      	}
      
      	public void beginConversation() {
      		if (conversation.isTransient()) {
      			conversation.setTimeout(120000);
      			conversation.begin();
      		}
      	}
      
      	public void endConversation() {
      		if (!conversation.isTransient()) {
      			conversation.end();
      			return;
      		}
      	}
      }
      

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                jhuska Juraj Húska
                Reporter:
                joerno Joern Ohmen
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: