Ustaw Focus dla Primefaces Component w Bean za pomocą WidgetVar z ExecContex Execute
Czy istnieje sposób na ustawienie fokusu mojego komponentu po wywołaniu funkcji innego komponentu z PrimeFaces RequestContex?
próbowałem:
RequestContex.getCurrentInstance().execute("PF('WidgetVar').focus();");
i
RequestContex.getCurrentInstance().execute("(((InputText) event.getComponent()).getWidgetVar()).focus();");
Nie dostaję błędu, ale nic się nie dzieje.
Czy tęskniłem za czymś, czy nie jest to możliwe?
Używam Primefaces 4.0.3 i MyFaces 2.0.2
EDYTOWAĆ Przykładowy kod
Fasola
import java.io.Serializable;
import java.util.logging.Logger;
import javax.annotation.PostConstruct;
import org.primefaces.context.RequestContext;
public class NavigationBean implements Serializable {
private static final long serialVersionUID = 1L;
private String input;
public NavigationBean() {}
@PostConstruct
public void init() {
}
public void goNext() {
Logger.getAnonymousLogger().warning("GONEXT");
RequestContext.getCurrentInstance().scrollTo("w3");
}
public String getInput() {
return input;
}
public void setInput(String input) {
this.input = input;
}
}
XHTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body >
<h:form id="form">
<h:inputText id="input1" value="#{navigationBean.input}" widgetVar="w1"></h:inputText>
<h:inputText id="input2" value="#{navigationBean.input}" widgetVar="w2"></h:inputText>
<h:inputText id="input3" value="#{navigationBean.input}" widgetVar="w3"></h:inputText>
<h:inputText id="input4" value="#{navigationBean.input}" widgetVar="w4"></h:inputText>
<p:commandButton value="focus" action="#{navigationBean.goNext()}" />
</h:form>
</h:body>
</html>