Choesang
Choesang

Reputation: 1225

JSF valueChangeListener not fired on form submission

On selecting a DIV element, i take the value of the selected DIV's hidden element and pass it on to a form with hidden element in it. This form is then submitted. Below are pieces of my code.

The value of the hidden input inside the form is correctly set on selecting the DIV and the form is also submitted but the valueChangeListener is not fired.

Every hint is welcome!

-choesang

Form with hidden element:

<a4j:form id="currentForumPost" ajaxSubmit="true" 
          onsubmit="console.log('currentForumPost is submitted'); 
          console.log(jQuery('#currentForumPost:currentPostId').val())" >
       <h:inputHidden id="currentPostId" 
       valueChangeListener="#{forumController.changeListenerSelectedForumPost}" 
       immediate="true"/>
</a4j:form>

DIV element:

<div class="block ui-accordion ui-widget ui-helper-reset"  
  onclick="var x = jQuery(this).find('.hiddenInputText').val();        
  jQuery(this).closest('#RightPane').find('#currentForumPost:currentPostId').val(x);      
  jQuery(this).closest('#RightPane').find('#currentForumPost').submit();">
  <h:inputText value="#{post.uuid}" styleClass="hiddenInputText"/>
                      ......
</div>

Java

public void changeListenerSelectedForumPost(final ValueChangeEvent event) {
setSelectedForumPost(event.getComponent().getAttributes().get("value").toString());  

}

Upvotes: 0

Views: 2907

Answers (1)

Colin Gislason
Colin Gislason

Reputation: 5589

It appears that you do not have a valueChangeListener attribute on the inputText. You need this attribute so JSF knows which listener to call. Assuming your bean is named 'bean', here is an example:

<h:inputText value="#{post.uuid}" valueChangeListener="#{bean.changeListenerSelectedForumPost}" styleClass="hiddenInputText" />

Upvotes: 1

Related Questions