Hi there, the easiest way to do this is using Jquery.
1) Make sure the part of section is invisble on the page load. 2) Attach Jquery click function to button, Onclick. 3) The above attached function and make it visible using jquery
Thanks guys for suggesting these methods. As of now, i tried the one suggested by Nithesh, somewhat. But m not getting the functionality properly.Even if m clicking the button, the block content isn't getting displayed. Here is what i implemented:
public class RenderController { public Boolean myb1{get;set;} public RenderController(){ this.myb1=false; } public void getB1() { if(this.myb1) { this.myb1=false; } else{ this.myb1=true; } } } Please check once if i missed out anything.
Nithesh, it's giving me vf Error stating: "Return type of an Apex action method must be a PageReference. Found: java.lang.Boolean " If something needs to be pulled from controller class to vfp, the return type chould be PageReference.
Thanks Nithesh. It is working now. So, can we imply that we need not mention "rerender" attribute in command Button component?? Because thats the only difference between this code n the previous one...
In that case, how could then "rerender" attribute be utilized?
Rerender can be utilized for table data...like pageblock table , which refreshes with new data. In a nut shell, we are not getting any new data from server (salesforce database), so rerender is not necessary.
Nithesh, I found a very unusual thing with this "Rerender" attribute. When I include PageBlockSection component inside that page block, n use this attribute in this component, the previous code is working exactly fine. VFP:-
It is working fine now.
VFP:
Controller:
Hope it helps...
If it solves your query, Please mark this solution as Best Solution to make this post 'Solved' .
Best,
Nithesh.
All Answers
1) Make sure the part of section is invisble on the page load.
2) Attach Jquery click function to button, Onclick.
3) The above attached function and make it visible using jquery
jq = $.noConflict();
jq('#sectionId').css('display', 'block')
Hope this helps!
Thank you
Prady01
Use this Code as reference.
You can follow the same logic for both standard and custom controller.
Vf Page:
Controller Ext:
Hope it helps...
If it solves your query, Please mark this solution as Best Solution to make this post 'Solved' .
Best,
Nithesh.
As of now, i tried the one suggested by Nithesh, somewhat. But m not getting the functionality properly.Even if m clicking the button, the block content isn't getting displayed.
Here is what i implemented:
VFP:-
<apex:page controller="RenderController">
<apex:form >
<apex:commandButton value="Get Block1" reRender="block1" action="{!getB1}"/>
<apex:pageBlock id="block1" rendered="{!myb1}">
Block 1 Rendered
</apex:pageBlock>
</apex:form>
</apex:page>
Controller:-
public class RenderController {
public Boolean myb1{get;set;}
public RenderController(){
this.myb1=false;
}
public void getB1() {
if(this.myb1)
{
this.myb1=false;
}
else{
this.myb1=true;
}
}
}
Please check once if i missed out anything.
VFP: Controller: Hope it helps...
If it solves your query, Please mark this solution as Best Solution to make this post 'Solved' .
Best,
Nithesh.
"Return type of an Apex action method must be a PageReference. Found: java.lang.Boolean "
If something needs to be pulled from controller class to vfp, the return type chould be PageReference.
Let me know if it works.
Best,
Nithesh
Still the issue persists..!!
It is working fine now.
VFP:
Controller:
Hope it helps...
If it solves your query, Please mark this solution as Best Solution to make this post 'Solved' .
Best,
Nithesh.
So, can we imply that we need not mention "rerender" attribute in command Button component?? Because thats the only difference between this code n the previous one...
In that case, how could then "rerender" attribute be utilized?
In a nut shell, we are not getting any new data from server (salesforce database), so rerender is not necessary.
I found a very unusual thing with this "Rerender" attribute.
When I include PageBlockSection component inside that page block, n use this attribute in this component, the previous code is working exactly fine.
VFP:-
<apex:page controller="RenderController">
<apex:form >
<apex:commandButton value="Get Block1" action="{!getB1}" />
<apex:pageBlock id="block1" >
<apex:pageBlockSection title="Rendered Section" rendered="{!myb1}">
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller:-(same as earlier)
public class RenderController {
public Boolean myb1{get;set;}
public RenderController(){
this.myb1=false;
}
public PageReference getB1() {
if(this.myb1)
{
this.myb1=false;
}
else{
this.myb1=true;
}
return null;
}
}