voyent
Inputtext handling valueChangeListener  XML
Forum Index -> General Help
Author Message
liviasilvasantos

Joined: 09/Dec/2008 00:00:00
Messages: 3
Offline


Hi,

I have this form with an inputtext that should handle both onblur event and enter key pressed.

I handle onblur event by adding partialSubmit=true and valuechangelistener inputtext's property and it works fine.

On the other hand, if I press enter key at the same inputtext element, it looks like I'm getting two or more requests to the Managed Bean. So the first time it enter valuechangelistener and I put a message add faces context. But the others requests seems to erase that message somehow.

So my question is: is it possible to handle both blur and enter key pressed and make it work correctly? If not, is there a way to prevent enter key (I tried javascript but it always sends a request)?

Is it possible to use f:ajax in Ice faces? Do I really need to use partialSubmit?

By the way, I'm using Ice Faces 3.1.0 and JSF Mojarra 2.1.19.
philip.breau


Joined: 08/May/2006 00:00:00
Messages: 2989
Offline


Hi,
First you might try out 3.3. Ajax request coalescing was added in 3.2, which might solve your problem. Although I haven't tested this with partialSubmit, and it might only be with ace:ajax requests. Could you post your xhtml?

Philip

.
liviasilvasantos

Joined: 09/Dec/2008 00:00:00
Messages: 3
Offline


Hi Philip,

I had some tests yesterday and what I assume:

-f:ajax and ace:ajax on icefaces 3.1.0 seems useless since partialSubmit is required anyway
-actionListener on an inputtext field works ok, but in my case, that I need to handle both onblur and onkeyup (code 13 for enter), gets overriden by valuechangelistener
-icefaces adds automaticaly an annoying onkeyup event that make a full submit

Anyway, here is my xhtml:

Code:
<h:form>
 <!--other inputtexts and selects up here-->
 <ace:dataTable id="eeTable" var="item" rowIndexVar="row" value="#{MBean.listaEE}" paginator="false">
 	<ace:column headerText="#{cat['numcol']}" id="numEECol" style="width: 10%">
 		<ice:inputText id="numEE" partialSubmit="true" immediate="true" styleClass="c70 mask-ee"
 			valueChangeListener="#{MBean.searchEE}" value="#{item.num}">
 			<f:attribute name="item" value="#{item}"/>
 			<script>
 				jQuery(document).ready(function(){
 					jQuery(".mask-ee").mask("9999-99", {placeholder: "0", autofilling: true});
 				});
 			</script>
 		</ice:inputText>
 	</ace:column>
 	<ace:column headerText="desccol" id="descCol">
 		<ice:outputText value="#{item.desc}"/>
 	</ace:column>
 	<ace:column headerText="#{cat['principalcol']}" id="principalEE" style="width: 16%">
 		<span>
 			<ice:selectOneRadio id="princiapalrdo" partialSubmit="true" immediate="true" 
 				valueChangeListener="#{MBean.selectPrincipal}" value="#{item.principal}">
 				<f:attribute name="item" value="#{item}"/>
 				<f:selectItem itemLabel="" itemValue="true" />
 			</ice:selectOneRadio>
 		</span>
 	</ace:column>
 	<ace:column headerText="" id="btnEE" style="width: 15%">
 		<ice:commandButton  id="addEEButtonTable" title="#{app['commandButton.add']}" 
 			action="#{MBean.addEE}" immediate="true"  partialSubmit="true">
 		</ice:commandButton>
 		<ice:commandButton id="removeEEButtonTable" title="#{app['commandButton.remove']}" 
 			actionListener="#{MBean.removeEE}" immediate="true"  partialSubmit="true">
 			<f:attribute name="item" value="#{item}"/>
 		</ice:commandButton>
 	</ace:column>
 </ace:dataTable>
 <!--button Save down here-->
 </h:form>
philip.breau


Joined: 08/May/2006 00:00:00
Messages: 2989
Offline


Have you tried just using an h:inputText with f:ajax? Partial Submit is a legacy attribute for the older ice components.

.
liviasilvasantos

Joined: 09/Dec/2008 00:00:00
Messages: 3
Offline


Philip,

I was trying to use ice:inputtext and f:ajax event="blur" but it only worked with partialSubmit. Now I tried h:inputtext and f:ajax event="blur".

Sometimes it works just fine although more than one request is executed.
Example: if I hit Enter inside a h:inputtext, it passes 2 or 3 times through valuechangelistener method.

The valuechangelistener method adds a new line to listaEE attribute. So after all requests processed, I get 2 or 3 new lines (and all I need is one).

In other hand, on blur event and using h:inputtext and f:ajax, it worked correctly.

I believe the main problem is still the same: when I hit Enter, I can't control how many times valuechangelistener method is called.

Thank you, Philip!

philip.breau


Joined: 08/May/2006 00:00:00
Messages: 2989
Offline


I haven't tested this inside a dataTable, but this works ok for me. The valueChangeListener only fires once for blur or the enter key:

Code:
 <h:inputText value="#{bean.value}" valueChangeListener="#{bean.valueChangeListener}">
     <f:ajax event="blur"/>
     <f:ajax event="keypress" onevent="if(event.keyCode == 13){ return true; } else return false;"/>
 </h:inputText>
 

.
 
Forum Index -> General Help
Go to:   
Powered by JForum 2.1.7ice © JForum Team