wood burning stoves 2.0*
The moose likes JSF and the fly likes Popup working with CommandButton but not with CommandLink Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Popup working with CommandButton but not with CommandLink" Watch "Popup working with CommandButton but not with CommandLink" New topic
Author

Popup working with CommandButton but not with CommandLink

Ashok Subramaniam
Greenhorn

Joined: May 07, 2008
Posts: 4
Hi All,

I have this piece of code which has a button when clicked brings up a popup page. This works as desired.

UIColumn _editColumn = new UIColumn();
HtmlCommandExButton _editCommand = new HtmlCommandexButton();

_editCommand.setStyleClass("commandButton");
_editCommand.setId("cmdEdit" + num + type);

String _editActionListener = "#{hksHandler.editHksLP}";
String _editAction = "#{hksHandler.editHksLPOutcome}";

Class[] params = { ActionEvent.class };

MethodBinding _editActionBindingListener = application.createMethodBinding(_editActionListener,params);
MethodBinding _editActionBinding = application.createMethodBinding(_editAction,null);

_editCommand.setActionListener(_editActionBindingListener);
_editCommand.setAction(_editActionBinding);

_editCommand.setOnclick("setPress('popup','FRTR')");

_editColumn.getAttributes().put("width","20px");
_editColumn.getChildren().add(_editCommand);
_dataTable.getChildren().add(_editColumn);

However, I wish to have a CommandLink that does the same job. Here is the code for CommandLink

UIColumn _editColumn = new UIColumn();
HtmlCommandLink _editCommand = new HtmlCommandLink();
HtmlOutputText _editText = new HtmlOutputText();

_editText.setValue("edit");
_editCommand.getChildren().add(_editText);
_editCommand.setStyleClass("commandLink");
_editCommand.setId("cmdEdit" + num + type);

String _editActionListener = "#{hksHandler.editHksLP}";
String _editAction = "#{hksHandler.editHksLPOutcome}";

Class[] params = { ActionEvent.class };

MethodBinding _editActionBindingListener = application.createMethodBinding(_editActionListener,params);
MethodBinding _editActionBinding = application.createMethodBinding(_editAction,null);

_editCommand.setActionListener(_editActionBindingListener);
_editCommand.setAction(_editActionBinding);

_editCommand.setOnclick("setPress('popup','FRTR')");

_editColumn.getAttributes().put("width","20px");
_editColumn.getChildren().add(_editCommand);
_dataTable.getChildren().add(_editColumn);

This does not bring me a popup page although the setPress() is a jsp function which is used to bring the popup page.

Please advice how I can solve this issue.

Thanks,
Ashok.
Venkat Sadasivam
Ranch Hand

Joined: May 10, 2008
Posts: 139
commandButton and commandLink are meant to submit form.

Use simple HTML code to invoke javascript like <input type="button" /> or <a href="javascript code" />


“Any fool can write code that a computer can understand. Good programmers write code that humans can understand. ”<br>
-Martin Fowler
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Popup working with CommandButton but not with CommandLink
 
Similar Threads
UIParameter issue in HtmlDataTable
HtmlCommandLink in a custom component
assigning parameters at runtime
setting action in commnad link not working in a dynamic dataTable
Dynamic Richfaces Tab Creation In Java Code ..How To Handle Create Event/Action