Hi all,
I have problem with the action event of dynamically created link. I have to create ajaxCommandLink dynamically. I can do that easily. But I am not able to provide action event OR action listener to that link.
I have tried the following, but didn't get success in that,
while(rs.next()) { HtmlAjaxCommandLink car_name = new HtmlAjaxCommandLink(); car_name.setValue(rs.getString("car_name")); Class[] params = {}; MethodExpression actionExpression = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createMethodExpression(FacesContext.getCurrentInstance().getELContext(), "#{car_details.action_car_details}", String.class, params); car_name.setActionExpression(actionExpression); int car_id = rs.getInt("car_id"); String onClick = "action_car_details(car_id)"; car_name.setOnclick(onClick); pnlgrp_car_assigned_detail.getChildren().add(car_name); }
public String action_car_details(int cid) { System.out.println("\n\t Selected car id : "+cid); . . . return null; }