我正在使用 a<rich:datatable>
来显示 a 的内容List<Map<String, String>
在下面的代码中,spotlightPtBindings是List<Map<String, String>
,spotlightbinding代表每个Map<String, String>
。在第一列中,我为每一行显示一个selectBooleanCheckBox。When a selectBooleanCheckBox is checked, I'd like to send the value of the Map<String, String>
corresponding to the key "URI" as a parameter to the method: inserirBean.onSelectedCheckBox(uri) , and that's why I put this value in a ui:param of名称:uri。这里的问题是,当我尝试打印在inserirBean.onSelectedCheckBox(uri)中收到的值uri,我没有得到任何输出,就好像它是空的一样。下面是其余的代码:
InsereDocumento.xhtml
<rich:dataTable value="#{inserirBean.spotlightPtBindings}" var="spotlightbinding">
<rich:column>
<f:facet name="header">*</f:facet>
<ui:param name="uri" value="#{spotlightbinding['URI']}"/>
<h:selectBooleanCheckbox value="#{selectionBean.selected}" />
<c:if test="#{selectionBean.selected}">
#{inserirBean.onSelectedCheckBox(uri)}"
</c:if>
</rich:column>
<c:forEach items="#{inserirBean.variableNamesPt}" var="vname">
<rich:column>
<f:facet name="header">#{vname}</f:facet>
#{spotlightbinding[vname]}
</rich:column>
</c:forEach>
</rich:dataTable> <br />
选择豆
package managedBeans;
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
@ManagedBean
public class CheckBoxSelectionBean implements Serializable {
private transient boolean selected = false;
private static final long serialVersionUID = 1L;
public CheckBoxSelectionBean() {
// TODO Auto-generated constructor stub
}
public boolean isSelected() {
return selected;
}
public void setSelected(boolean selected) {
this.selected = selected;
}
}
InserirBean - 我没有在这里展示List<Map<String, String>>
命名的SpotlightPtBinding和List<String>
variableNamesPt是如何填充的,因为这是一个复杂的过程,但我可以告诉你它们肯定是填充的,因为我可以在屏幕上看到它们的内容。
@ManagedBean
public class InsereDocumentoBean implements Serializable {
private static final long serialVersionUID = 1L;
private List<String> variableNamesPt = new ArrayList<String>();
private List<Map<String, String>> spotlightPtBindings = new ArrayList<Map<String, String>>();
public List<String> getVariableNamesPt() {
return variableNamesPt;
}
public List<Map<String, String>> getSpotlightPtBindings() {
return this.spotlightPtBindings;
}
public void onSelectedCheckBox(String uri) {
System.out.println("URI: " + uri);
}
}
问题可能是什么?谢谢!我是 JSF 的新手,需要您的帮助!