a4j:commandLink calling all actions in xhtml!!
mcohnen Oct 21, 2009 7:31 PMHi,
obviously there's something I'm missing with richfaces a4j... This is the simple example I have made.
Here the xhtml
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:s="http://jboss.com/products/seam/taglib"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:rich="http://richfaces.org/rich"
xmlns:a="http://richfaces.org/a4j"
template="layout/template.xhtml">
<ui:define name="body">
<ul>
<ui:repeat var="_i" value="#{test.strings}">
<li>#{_i}</li>
</ui:repeat>
</ul>
<s:div id="date">
#{test.date}
</s:div>
<h:form>
<a:commandLink value="Go" action="#{test.nothing}" reRender="date"/>
</h:form>
</ui:define>
</ui:composition>Here the Test Component
package es.cohnen.pistayhora.session;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.jboss.seam.annotations.Name;
@Name("test")
public class Test {
private Date date = new Date();
public void nothing(){
System.out.println("Doing nothing...");
date = new Date();
}
public List<String> getStrings(){
System.out.println("Loading strings...");
List<String> res = new ArrayList<String>();
for (int i=0; i<20; i++){
res.add(""+i);
}
return res;
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
}
What I want: I want to print the ul in the site, and then, when I click the a4j link, I want the 'nothing' method to be called, but without calling the 'getStrings' method (Or whatever another method was called in the xhtml file.
The traces I get are:
19:28:31,379 INFO [STDOUT] Loading strings... (First call, loading page) 19:28:36,145 INFO [STDOUT] Loading strings... (ajax call) 19:28:36,161 INFO [STDOUT] Doing nothing... (ajax call)
Why is the 'getStrings' method called when I click my a4j link? I have tried using bypassupdates, singleAjax, immediate... none of them did the job...
Thank you in advance! I hope it is clear enough!