Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsf 用Javascript更改Primefaces p:steps activeIndex?_Jsf_Primefaces - Fatal编程技术网

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没有定义。无论如何,谢谢,我会尝试你的方法…步骤组件不是javascript意义上的“小部件”。这可以从中看出。因此,它没有javascript api,从这个意义上说,它是一个“只读”组件。谢谢。我正要报告一个错误。
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);
}