You need to sign in to do that
Don't have an account?
Problem with "rerender" and redirect
Hi everyone.
I have a bit of a problem that I have been trying to get around for quite awhile now. I wrote a previous post (http://community.salesforce.com/t5/Visualforce-Development/Problem-with-Component-in-javascript/m-p/190323#M25337) about a problem I had where I was trying to get around issues with one type of workaround I tried, but have been unable to resolve that.
Rather than focus on my current failed attempt at getting around this I am now presenting my problem as it is, in hope that someone out there might see this from another perspective and offer some insights.
What I have is a visualforce page with a controller extension that runs within an iframe in a custom object's page layout (see screenshot below). What this does is allow users to edit certain properties of a related object in-line on the current page layout, without having to open each line up. This is done by the user by clicking the "QuickEdit" link for each line, and then either "Save" or "Cancel".
When the Save link is clicked (#3 on screenshot) I always want the controller to fire up, do some logic, including saving the record obviously, but then, based on the selection in one of the picklists (#4 on screenshot) I want the return to either just refresh the list (#2 on screenshot), or redirect the parent page (#1 on screenshot) to a different location.
I am able to easily hardcode this to always do one of the two by setting the "rerender" or "target" properties of the commandLink (#3), but I want this to change dynamically based on the selection in (#4).
Now the render properties are set in the attributes of the commandLink (#2) element and are thus already set when the controller receives the request making it impossible (I think) for me to manipulate the return target from the controller, so I have been trying to use javascript to do this, without much success. I have been trying to call a javascript function on the "onChange" event of the controlling element (#4), but the javascript can only access DOM elements and thus can only change the commandLink's "target" attribute, not it's VF-specific "rerender" property.
I hope I managed to describe what I am dealing with, and hopefully someone has a suggestion for me that might work.
Best regards,
Ivar
I'm surprised (well, not that surprised) that the SF default is as an iframe.
Here is a workaround that I am pretty sure will work for you:
May seem a bit dirty but I've used it and it works.
All Answers
Maybe I'm missing something but I think what you want to do is:
Then in your controller:
That will forward the page whenever the property of the custom object equals the desired value.
Hi d3developer and thanks for your reply.
What you are suggesting is indeed exactly what I am doing. This does however not give me the desired effect as what this will do is just send the newPage to the iframe.
What I want is that when the special conditions are met is not to get a rerender of "innerList", but instead the whole page to be redirected to the newPage.
EDIT:I should point out that I have tried using target="_parent" as well, which is probably correct based on what I am trying to do , but the rerender property seems to override the target information
You might try this instead of an iframe: http://blog.sforce.com/sforce/2009/04/an-approach-to-inplace-editing-with-visuaforce.html
Thanks again for your feedback and help d3developer. I appreciate it.
The example you point to is indeed what I am basing my implementation on. Only difference is that I cannot run it as a standalone Visualforce page, but need it to run as a Visualforce component within a standard page layout.
Regards,
Ivar
You still shouldn't need an iframe in that case. Mind sharing your page source?
It's a little hacky, but for what it's worth:
How about having multiple save links, with specific rendered properties ensuring only one is visible at a time. Combined with an actionSupport tied to the onChange of #4, you could flip a flag in your controller, trigger a rerender of your list which would change which of the save links was being displayed, allowing you to get either the rerender property you want, or completely omitting it and having the parent you want.
I'm guessing that it won't be ideal due to rendering delays on the triggering onChange, but it's something.
Thanks again d3developer. I don't mind at all. Here are the visualforce page and the apex controller. Keep in mind that this is a work in progress so it's not the cleanest of code :)
How can I avoid this being rendered as an iframe? I am using this as an inset on a page layout, and I thought the system would always render that in an iframe. (See my screenshot below)
Here is the visualforce page:
This is the controller extension:
And here is a screenshot of my page layout:
Again my thanks for all the help.
Ivar
Thanks for the idea MikeGinou, nice outside-the-box thinking going on there :)
I would however like to avoid the rendering delays you mentioned. But it's a possibility as a last resort.
Thanks :)
I'm surprised (well, not that surprised) that the SF default is as an iframe.
Here is a workaround that I am pretty sure will work for you:
May seem a bit dirty but I've used it and it works.
Thanks a bunch. I'll try this workaround and let you know how it turns out :)
My best thanks d3developer for all the effort, this finally worked, thanks to your help!