function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sslatersslater 

Avoiding Page Refresh on Render

Hi,

I have an VF page with a datatable component. Inside the table, I am using a commandlink to toggle and inputtext field on and off. Something like:

Entry1   link    [input]
Entry2   link    [input]

etc...

So the commandlink for each row chagnes a boolean in the list object. That boolean is used by the input field to set the rendered component.

The idea is when I click the link, it changes the render boolean and should then render the box. The problem is that when I do this, the entire page reloads. It works correctly, but refreshes the entire page.

In JSF, I can use the "visible" tag and some frameworks do not refresh the entire page on a render change like this.

Is there a smoother way to do this without having the full page refresh? I think I could use a script to set the CSS visible property instead and just hide it until I click the link, but that is somewhat ugly. Anyone have a way to show and hide elements without forcing a full page refresh?

Thanks!
jwetzlerjwetzler
are you using the rerender attribute on your commandLink to specify what gets rerendered?  Because if you don't, your page will refresh.
Arun BalaArun Bala
Hi sslater,
I have also implemented something like this in one of my projects. As Jill mentioned, if you reRender just the datatable component alone, your problem would be solved.

But there is a small catch in it .. any changes you make on the data table (if the datatable has some inputFields or any editable fields) before the click of the link might be lost when you rerender the entire datatable as the original list that holds your data might be repopulated. I mean you might lose the uncomitted data on the datatable during reRender. Thats why you might want to include some Java Scripting in the picture ...


Thanks


Message Edited by Arun Bala on 12-31-2008 01:58 PM

Message Edited by Arun Bala on 12-31-2008 01:58 PM
jwetzlerjwetzler
I'm not sure what you mean by "losing the uncommitted data".  As long as the data inside of your data table is bound to a field or property in your controller the state will be maintained...

There should not be any javascript required to make this work.
DSLDSL
I had a similar issue. I used the rerender but I could not set the component ID based on the "var" component of a datatable. Like:

<apex:dataTable value="{!list}" var="s" id="tw" >

    columns and other stuff...

    <apex:outputpanel id="{!s.uniqueid}">

etc...


It gives an error saying it needs a getS method. So I had to just rerender the table itself. It would be convenient to reference each row in the table individually by the controller to set rendered, etc...

Any thoughts on how to do it?

sslatersslater
Thanks Jill, works great now.