trouble calling rerender on an inputtext element with ajax4jsf

I'm trying to do something with Ajax4jsf that seems like it should be very simple. I have an input field ("longitude") and, when an onkeyup event fires within it, I want to change the value of another input field ("ownership"). The idea is that the onkeyup in "longitutde" fires the "loadOwnership" method that sets the "ownership" property. Currently it sets it to a current datstamp for testing purposes and outputs a notice that I have hit the method. However, when I type in the "longitutde" field, the "ownership" field does not change and nothing prints to standard out. I do have the bean set to "session" scope, can anyone see what I'm doing wrong?

Thanks,

Alex

JSP page

<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>

<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>

<%@ taglib uri="https://ajax4jsf.dev.java.net/ajax" prefix="a4j"%>

<HTML>

<HEAD> <title>Facility Form</title> </HEAD>

<body bgcolor="white">

<f:view>

<h2>Facility Form</h2>

<h:form id="locationForm">

<h:panelGrid columns="3" style="margin-top:10px;">

<h:outputText value="Longitude:" />

<h:inputText id="longitude" value="#{locationForm.longitude}" >

<a4j:support event="onkeyup" action="#{locationForm.loadOwnership}" reRender="ownership" />

</h:inputText>

<h:outputText value="&nbsp;" escape="false"/>

<h:inputText id="ownership" value="#{locationForm.ownership}" />

<h:outputText value="&nbsp;" escape="false"/>

<h:commandButton value="Submit" action="#{locationForm.submitNewLocation}" />

<h:outputText value="&nbsp;" escape="false"/>

<h:outputText value="&nbsp;" escape="false"/>

</h:panelGrid>

<h:outputText value="#{locationForm.confirmText}" escape="false" />

</h:form>

</f:view>

</body>

</html>

Bean Source

package forms;

import javax.faces.context.FacesContext;

import java.sql.ResultSet;

import java.sql.Statement;

import java.util.ArrayList;

import java.sql.*;

import control.Connector;

import java.util.*;

import java.io.*;

import javax.faces.component.html.HtmlDataTable;

publicclass Location{

public Location(){

}

publicvoid loadOwnership(){

System.out.println("in loadOwnership");

this.ownership =new java.util.Date().toString();

}

/* --

Get Methods

*/

public Double getLongitude(){

return this.longitude;

}

public String getOwnership(){

return this.ownership;

}

/* --

Set Methods

*/

publicvoid setLongitude(Double longitude){

this.longitude = longitude;

}

publicvoid setOwnership(String ownership){

this.ownership = ownership;

}

}

[5229 byte] By [bonemachinea] at [2007-11-26 19:51:33]
# 1

After checking around some other forums, I was able to solve this by adding ajaxSingle="true"

to the a4j:support element. To be honest, I'm not totally clear on why this solves the problem, but it does seem to be the magic pixie dust that makes it all work. Does anyone have a clear explanation on this?

Thanks,

Alex

bonemachinea at 2007-7-9 22:41:44 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Alex, you posted this question to two places. Where you want me to answer. It is an interesting case, because It is a feature of jsf how it optimizes the performance working with the component tree.
Sergey.Smirnova at 2007-7-9 22:41:44 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
It should work if the actionlistener method is defined with the ActionEvent parameter.
millica at 2007-7-9 22:41:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...