users@woodstock.java.net

Re: weird refresh() behaviour in table

From: Lking <lking4hlp_at_yahoo.com.br>
Date: Wed, 2 Apr 2008 08:27:06 -0300

Hi Dan,

I'd likw to know how can I build a JS so that #3 will be changed according
to the row the action was performed?

        var domNode =
document.getElementById("form1:table1:rowGroup1:3:col1:_button");

thanks.

On Fri, Feb 8, 2008 at 5:50 PM, Dan Labrecque <Dan.Labrecque_at_sun.com> wrote:

> I modified the Woodtsock dynamic table example to include buttons
> (created using Java). I used a value expression to set each button label
> using a date. Then, I wrote some JavaScript to refresh a particular button
> in the table. Unlike you, I only saw one button being refreshed with a new
> date value. Below are a couple snippets of code used in my test.
>
> In the example's Dynamic.java class, I added the following code.
> Basically, all this does is add a button child to the TableColumn object
> (i.e., col2).
>
> public Button getButton(String id, String text) {
> // Get checkbox.
> Button btn = new Button();
> btn.setId(id);
> JSFUtilities.setValueExpression(btn, "text", text); // Set text
> using value expression.
> return btn;
> }
>
> public void setTableRowGroupChildren(TableRowGroup rowGroup, String
> cbSort,...
> ...
> Button btn = getButton("_button", "#{DynamicTableBean.time}");
> col2.getChildren().add(btn);
>
> Then, in my DynamicTableBean.java class, I added the following function to
> retrieve a date for the button label.
>
> public String getTime() {
> Calendar calendar = Calendar.getInstance();
> return calendar.getTime().toString();
> }
>
> Finally, I included a simple control used to refresh a button of a
> particular table row. If all buttons were being refreshed, as you suggest, I
> should see all button labels updated with a new date. However, I only saw
> one button label updated as expected.
>
> <input type="button" onClick="refreshButton();" value="Test Refresh"/>
> <script>
> function refreshButton() {
> var domNode =
> document.getElementById("form1:table1:rowGroup1:3:col1:_button");
> domNode.refresh();
> }
> </script>
>
> If you're still seeing all buttons being refreshed, take a look at the
> Ajax response in Firebug. You should see text containing button properties
> and not raw HTML. If you see HTML, JSF may have re-rendered the entire page.
> There could be many reasons for this, but JSF most likely could not locate
> the button in the JSF component tree. For example, the wrong button id was
> used. Or, the same DataProvider was not available to JSF during the decode
> phase. You can test that by setting the backing bean to be session scoped.
>
> Sorry, I cannot be more helpful.
>
> Dan
>
>