[jboss-user] [JBoss Seam] - Re: Two browser tabs : basic question
damianharvey
do-not-reply at jboss.com
Fri Dec 21 07:37:46 EST 2007
I don't think that there's anything *wrong* with @RequestParameter, but it isn't optional so your Bean containing it must always be passed it.
Using just page params is just as easy. You would do something like this:
test.xhtml:
| <a4j:outputPanel id="testPanel">
| <h:dataTable
| id="testTable"
| var="row"
| value="#{testBean.widgets}">
| <h:column>
| #{row.id}
| </h:column>
| <h:column>
| <s:link
| action="#{testBean.deleteWidget}">
| Normal Delete
| <f:param name="id" value="#{row.id}"/>
| </s:link>
| <a4j:commandLink
| action="#{testBean.deleteWidget}"
| ajaxSingle="true"
| reRender="testPanel">
| AJAX Delete
| <f:param name="id" value="#{row.id}"/>
| </a4j:commandLink>
| </h:column>
| </h:dataTable>
| </a4j:outputPanel>
|
test.page.xml:
| <param name="id" value="#{testBean.id}"/>
|
TestBean.java
| @Name("testBean")
| public class TestBean {
| private long id;
| private List<Widget> widgets = new ArrayList<Widget>
|
| public long getId() {
| return this.id;
| }
|
| public void setId(long id) {
| this.id = id;
| }
|
| public void deleteWidget() {
| Widget widget = entityManager.find(Widget.class, this.id);
| entityManager.remove(widget);
| widgets.remove(widget);
| }
|
| public List<Widget> getWidgets() {
| if(this.widgets == null || this.widgets.size == 0) {
| loadWidgets();
| }
| return this.widgets;
| }
| private void loadWidgets() {
| this.widgets = entityManager.createQuery("select w from Widget w").getResultList();
| }
|
Hope this helps.
Cheers,
Damian.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4114962#4114962
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4114962
More information about the jboss-user
mailing list