commandlink总是 会失效,我没有用dataTable,
而commandButton不能传参,大家有没有好的建议呀,
烦呀。

解决方案 »

  1.   

    用f:param传递参数给后台,这样,你就能在函数里获取参数
    但注意f:param只能对commandLink起作用, 
    用f:attribute比较好 
    例子如下: 
    <h:commandButton value="Press here" actionListener="#{myBean.action}"> 
            <f:attribute name="attrname1" value="attrvalue1" /> 
            <f:attribute name="attrname2" value="attrvalue2" /> 
            ... 
    </h:commandButton>     public void action(ActionEvent event) 
        {  
            String attrvalue1 = (String) event.getComponent().getAttributes().get("attrname1"); 
            String attrvalue2 = (String) event.getComponent().getAttributes().get("attrname2"); 
            ... 
        }
    f:attribute还有个注意点就是别使用标准的组件属性名 
    比如:id,name,binding等等,会有冲突
      

  2.   

    commandlink总是 会失效    //为什么会失效? 传参不进去?页面报JS错误? 是使用<a4j: commandlink/> 还是<h: commandlink/> ?
                             建议你就用<h: commandlink/>
    列如:
    <h:commandLink  id="button" 
    action="#{你的Bean.你的方法}" value="提 交">
    <f:param name="id111" value="#{你的Bean.你要传到Bean里面的值}" id="aa"/>
    </h:commandLink>
    commandButton不能传参,大家有没有好的建议呀  //是使用<a4j: commandButton/>还是<h: commandButton/>?
    <a4j: commandButton/> 只会局部刷新提交,是指定区域的
    <h: commandButton/>  会提交你所在的当前<h:form>表单的所有内容。 建议你用这个