Jsf 用Javascript更改Primefaces p:steps activeIndex?
我正在考虑使用Jsf 用Javascript更改Primefaces p:steps activeIndex?,jsf,primefaces,Jsf,Primefaces,我正在考虑使用p:steps组件 <p:steps activeIndex="1" styleClass="custom" readonly="false"> <p:menuitem value="Personal" url="#"/> <p:menuitem value="Seat Selection" url="#"/> <p:menuitem value="Payment" url="#"/> <p:me
p:steps
组件
<p:steps activeIndex="1" styleClass="custom" readonly="false">
<p:menuitem value="Personal" url="#"/>
<p:menuitem value="Seat Selection" url="#"/>
<p:menuitem value="Payment" url="#"/>
<p:menuitem value="Confirmation" url="#"/>
</p:steps>
如何使用Javascript更改activeIndex?通常,您应该能够使用Javascript API和
widgetVar
属性来更改activeIndex。但是,当我使用widgetVar=“stepsVar”
时,小部件是未知的(JavaScript控制台):
PF('stepsVar')
var'stepsVar'的小部件不可用!
所以,恐怕你需要一些变通办法。例如,将索引保存在托管bean中,并使用
XHTML
试验
豆子
private-int-stepIndex;
public int getStepIndex()
{
回归指数;
}
public void setStepIndexByRemoteCommand()
{
FacesContext context=FacesContext.getCurrentInstance();
Map Map=context.getExternalContext().getRequestParameterMap();
字符串indexString=map.get(“index”);
stepIndex=Integer.valueOf(indexString);
}
另见
widgetVar
属性确实有误导性。我遇到的另一个bug是绑定steps组件。在这种情况下,会生成重复的ID。请这样做,这会产生误导。我之前跟PF的人提到过,如果使用了不受支持的属性,他们的组件不会抛出错误。而showcase中的“交互式”版本对我没有任何帮助,所以看起来好像有什么地方出了问题(嗯,是的……只需导航到当前页面)
private int stepIndex;
public int getStepIndex()
{
return stepIndex;
}
public void setStepIndexByRemoteCommand()
{
FacesContext context = FacesContext.getCurrentInstance();
Map<String, String> map = context.getExternalContext().getRequestParameterMap();
String indexString = map.get("index");
stepIndex = Integer.valueOf(indexString);
}