THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
Code Block | ||||
---|---|---|---|---|
| ||||
<h:commandLink actionListener="#{employeeAction.prepareForEdit}"> <h:outputText value="#{msgs.edit}" /> </h:commandLink> |
Code Block | ||||
---|---|---|---|---|
| ||||
public void prepareForEdit(ActionEvent anEvent) {
YourBeanClass tmpBean = null;
UIComponent tmpComponent = anEvent.getComponent();
while (null != tmpComponent && !(tmpComponent instanceof UIData)) {
tmpComponent = tmpComponent.getParent();
}
if (tmpComponent != null && (tmpComponent instanceof UIData)) {
Object tmpRowData = ((UIData) tmpComponent).getRowData();
if (tmpRowData instanceof YourBeanClass) {
tmpBean = (YourBeanClass) tmpRowData;
//TODO Implementation of your method
}
}
//TODO Exception Handling if UIData not found or tmpRowBean of wrong type
}
{code:java}
# You could also use the |
...
...
...
...
If
...
you
...
are
...
coming
...
from
...
Struts
...
or
...
some
...
other
...
servlet
...
MVC
...
framework
...
you
...
may
...
have
...
previously
...
solved
...
this
...
problem
...
by
...
passing
...
some
...
kind
...
of
...
primary
...
key
...
as
...
request
...
parameters
...
as
...
part
...
of
...
a
...
link,
...
perhaps
...
via
...
something
...
like
...
this:
...
Code Block | ||||
---|---|---|---|---|
| ||||
<a href="/appContext/someAction.do?id=1234&userAction=prepareEdit">Edit</a> |
Using JSTL to create the above:
...