Click here to Skip to main content
15,893,381 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi, I've got a problem with ajax4jsf component commandButton.

I have one component (let's call it MyComponent. It represents just a XHTML page which is included on the page by specific tag) and one XHTML page.
The component contains an inputText (jsf component) and the commandButton(a4j component) which execute a method from the Bean.
The page contains the component MyComponent and a dataTable (RichFaces component).

When the commandButton is pressed (from MyComponent, executing the method) I need to re-render the dataTable(using attribute reRender). To do that, I need to transmit an id of the dataTable to the attribute reRender of the commandButton.

So the question is how can I do it, if the commandButton is situated in the component MyComponent(In other words: in another xhtml page) and the dataTable is situated on the page MyPage.xhtml ?

CodeSnippet:

1) MyComponent.xhtml:
XML
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:a4j="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich">

<ui:composition>
......
<a4j:commandButton value="Click"
       action="#{bean[method]}"
       id="search"
       reRender="#{reRenderTable}" /> <!-- dont know if it is correct -->

</ui:composition>


2) MyPage.xhtml

<html>
...
    xmlns:myTags=http://myTagsLig.com/tags/tagsLib
    xmlns:rich=http://richfaces.org/rich
.....
<!-- MyComponent -->
<mytags:mycomponent xmlns:mytags="#unknown">
...
reRenderTable="table"  <!-- how here to transfer the id of the dataTable -->
</mytags:mycomponent>
....

<rich:datatable id="table" xmlns:rich="#unknown">
</rich:datatable>
Posted
Updated 25-May-11 23:29pm
v8

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900