简体   繁体   English

JSF 1.1 f:param不在WAS 5中工作

[英]JSF 1.1 f:param not working in WAS 5

I'm using JSF 1.1 in WAS 5 (Websphere Application Server 5), and I need to know what Column in my HtmlDataTable was clicked, I have tried by many ways but I can not get a Success result, the only thing I need is to pass a parammeter to an action. 我在WAS 5(Websphere Application Server 5)中使用JSF 1.1,我需要知道我的HtmlDataTable中的哪个Column被点击了,我已经尝试了很多方法但是我无法获得成功结果,我唯一需要的是将参数传递给动作。

I have something like 我有类似的东西

<h:form>
<h:datatable value=#{bean.list} var="row">
       <h:column>
            <f:facet name="header">
                        <h:outputText value=""/>
                    </f:facet>  
            <h:commandButton value="Test!" action="#{bean.saludar}">
                  <f:param name="cod" value="#1"/>
            </h:commandButton>
       </h:column>
</h:datatable>
</h:form>

In my BackingBean I have 在我的BackingBean中我有

public class Bean {
       ......
       ......
     public String saludar() {

           FacesContext context = FacesContext.getCurrentInstance();
           Object value = context.getExternalContext().getRequestMap().get("cod");
           //value IS NULL !!!!!!!!!!!!!!!!!!! HELP HERE OR BEFORE ....
     }

}

I have tried many ways, I don't know if the problem is because I am inside a HtmlDataTable or something like that, I can know the selected Row by binding de table to one HtmlDataTable and accesing to the method table.getRowData(); 我已经尝试了很多方法,我不知道问题是因为我在HtmlDataTable中或类似的东西,我可以通过将de表绑定到一个HtmlDataTable并访问方法table.getRowData();来了解所选的Row。 I have almost 3 days And i can not find a solution, I have tested in JSF 1.2 With Glassfish 3.1 and it worked, but I dont know how to get work that in WAS 5 with Java 1.4 我有将近3天而且我找不到解决方案,我已经在使用Glassfish 3.1的JSF 1.2中进行了测试并且它有效,但我不知道如何使用Java 1.4在WAS 5中完成工作

Thnkxx !! Thnkxx !!

In JSF 1.x, the <f:param> is not supported in command buttons. 在JSF 1.x中,命令按钮不支持<f:param> This support is since JSF 2.0 only. 此支持仅适用于JSF 2.0。

There are several ways to achieve your concrete requirement (btw, the requirement to know the clicked column is quite strange, perhaps you actually meant "row" when you said "column"?). 有几种方法可以达到你的具体要求(顺便说一句,要知道点击的列是非常奇怪的,当你说“列”时,你实际上可能意味着“排”?)。

  1. Use <h:commandLink> instead of <h:commandButton> . 使用<h:commandLink>代替<h:commandButton> It supports <f:param> . 它支持<f:param>
  2. Use <f:setPropertyActionListener> instead of <f:param> . 使用<f:setPropertyActionListener>代替<f:param>
  3. Use UIData#getRowData() or DataModel#getRowData() instead to obtain the current row. 使用UIData#getRowData()DataModel#getRowData()来获取当前行。
  4. Install JBoss EL and just pass the row itself directly like so action="#{bean.saludar(row)}" . 安装JBoss EL并直接传递行本身就像action="#{bean.saludar(row)}"

See also: 也可以看看:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM