0

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.

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

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(); 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

Thnkxx !!

Brett Kail
  • 33,593
  • 2
  • 85
  • 90
Daniel Hernández
  • 4,078
  • 6
  • 27
  • 38
  • I have given this solution earlier, it shows which button u clicked may be this is what you are looking for http://stackoverflow.com/questions/12797539/how-to-identify-clicked-commandbutton-in-my-managed-bean/12798536#12798536 – Swarne27 Oct 25 '12 at 06:44

1 Answers1

3

In JSF 1.x, the <f:param> is not supported in command buttons. This support is since JSF 2.0 only.

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>. It supports <f:param>.
  2. Use <f:setPropertyActionListener> instead of <f:param>.
  3. Use UIData#getRowData() or DataModel#getRowData() instead to obtain the current row.
  4. Install JBoss EL and just pass the row itself directly like so action="#{bean.saludar(row)}".

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555