2008-12-12 20:28:39 UTC
I’m sure the answer to this is somewhere on page 1 of the docs, but I just can’t quite get a handle on it. I have a very basic, out-of-the-box JSF app (Sun JSF, version 1.1), and I want to add ajaxanywhere functionality to one page. I need to click a button, execute some code in the backing bean, and produce a partial refresh of my page (only the elements inside "testZone"). Unfortunately, I just can't quite seem to get it to work. The backing bean fires, but the entire page always refreshes rather than just the piece I want. Any help would be much appreciated.
Thanks,
Alex
<%@ taglib uri="
http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="
http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib prefix="aa" uri="
http://ajaxanywhere.sourceforge.net/" %>
<html>
<head>
<title>JSF Test Form</title>
<script type="text/javascript" src="js/aa/aa.js"></script>
</head>
<body>
<f:view>
<h1>
<aa:zoneJSF id="testZone">
Text: <h:outputText value="#{testajax.text}"/>
<br />showText: <h:outputText value="#{testajax.showText}"/>
</h1>
<h:form id="helloForm">
<h:inputText value="#{testajax.text}" />
<br /><h:inputText value="#{testajax.otherText}" />
<h:commandButton id="testAAButton" action="#{testajax.runTest}" value="Push Me" />
</h:form>
</aa:zoneJSF>
<P>This part should not refresh
<br />
<input type="text " />
</P>
<script type="text/javascript">
ajaxAnywhere.getZonesToReload = function(url, submitButton) {
if (typeof submitButton != 'undefined') {
if (submitButton.type == 'submit') {
if (submitButton.id.search('testAAButton') != -1) {
return 'testZone';
}
}
}
return null;
}
var elements = new Array(); elements.push(document.getElmById('testAAButton'));
ajaxAnywhere.formName = 'helloForm'; ajaxAnywhere.substituteFormSubmitFunction();
ajaxAnywhere.substituteSubmitButtonsBehavior(true, elements);
</script>
</f:view>
</body>
</html>