Apex:Component refresh on page rerender - salesforce

again, lovely people.
Having an issue with getting an apex:component to refresh when the page reloads, and I can't seem to figure out what to do with it.
We've tried everything from putting the component in an outputPanel and adding that to the rerender attribute, reloading the entire page with an oncomplete, using the window.reload (something like that) function, and even tried forcing a reload with setTimeout.
While I'm able to get the entire page itself to reload, the component never does until you actually go up and click the "refresh" button on the browser.
A demo of the code is below:
<apex:page controller="myController" id="thePage" showHeader="false" sidebar="false" applyHTMLTag="false" standardStylesheets="false" action="{!onStart}">
<apex:composition template="myTemplate">
<apex:define name="header">
<c:myHeader fixed="true" language="{!langPref}" filling="true" timeout="true" /> <!--appStatus="{!app.App_Status__c}"-->
</apex:define>
<apex:define name="sidebar" >
<c:mySidebar id="theSidebar" applicationCurrentStage="{!currentStage}" applicationMaxStage="{!app.Application_Stage__c}" stages="{!appPagesMetadata}" memberSegmentedStages="{!memberSegmentedStages}" stagesToInvalidate="{!stagesToInvalidate}" currentMemberIndex="{!memberIndex}" members="{!members}" application="{!app}"/>
</apex:define>
<apex:define name="contents">
<p>There's totally some stuff in here.</p>
<div class="form-group">
<div class="col-lg-12">
<apex:commandButton action="{!save}" value="{!$Label.Save_Progress}" rerender="thePage" rendered="{!app.Application_Stage__c==NEW_STAGE && !guestUser}" oncomplete="myJS.afterSave({!isSaved},false);" status="blockStatus" />
<!--Functionality to Save and go Next-->
<apex:commandButton action="{!saveAndNext}" value="{!IF(previousStage==app.Application_Stage__c||app.Application_Stage__c==NEW_STAGE,$Label.Save_Next_btn ,$Label.Save_Progress)}" rerender="theForm" oncomplete="myJS.afterSave({!isSaved},true);" status="blockStatus" rendered="{!NOT(guestUser) || NOT(captchaEnabled)}" />
<apex:commandButton action="{!verifyCaptcha}" value="{!IF(previousStage==app.Application_Stage__c||app.Application_Stage__c==NEW_STAGE,$Label.Save_Next_btn,$Label.Save_Progress)}" rerender="thePage" oncomplete="myJS.afterSave({!isSaved},true);" status="blockStatus" rendered="{!guestUser && captchaEnabled}" />
<apex:actionFunction action="{!nextPage}" name="nextPage" status="blockStatus" />
<!--Functionality to Go To Page based on Sidebar preference-->
<apex:actionRegion renderRegionOnly="true">
<apex:outputPanel id="fastRerenderPanel" />
<apex:actionFunction action="{!findPage}" name="goToPage" status="blockStatus" reRender="fastRerenderPanel" oncomplete="redirectToPage();">
<apex:param name="goToPage" id="goToPage" assignTo="{!goToPage}" value="" />
<apex:param name="memberIndexNavigation" id="memberIndexNavigation" assignTo="{!memberIndex}" value="" />
</apex:actionFunction>
<apex:actionFunction action="{!redirectToPage}" name="redirectToPage" status="blockStatus" />
</apex:actionRegion>
<apex:actionStatus id="blockStatus" onstart="myJS.blockScreen();" onstop="myJS.unblockScreen();" />
</div>
</div>
</apex:define>
</apex:composition>
</apex:page>
Thanks again, everyone.

Related

Salesforce: Creating a User Registration Form using VisualFocre

I have below requirement to Create a VF page – ‘Registration Forum’ having
1.Name field
2.Age field
3.Project Unit field
4.Gender as Radio Button with values – M and F
5.Certification as Picklist with Values – PD1, ADM 201, PD2, App Builder, Sales Cloud, Service Cloud
6.2 buttons – save and reset
7.Attachment area – where we can browse and add any document there.
Save Button – A record should get created in one object (Any object u can mention)
Reset Button – Page should not get refreshed, just values get refreshed with blank value.
As I am new to SFDC, could you please help me to get it done?
Thanks
It's hard to tell from your question exactly what you're looking for, but here is a visualforce page that saves to a custom object called Form__c.
To do the save and reset you'll probably need an Apex extension. I'm not sure if your browse documents is for Salesforce documents or local files.
<apex:page standardController="Form__c" >
<apex:form>
<apex:pageBlock>
<apex:pageBlockButtons>
<apex:commandButton value="Save" action="{!save}" />
</apex:pageBlockButtons>
<apex:pageBlockSection>
<apex:inputField value="{!Form__c.Name}" />
<apex:inputField value="{!Form__c.Age__c}" />
<apex:inputField value="{!Form__c.Project_Unit__c}" />
<apex:selectRadio value="{!Form__c.Gender__c}" ><apex:selectOption itemValue="Male" itemLabel="Male" /><apex:selectOption itemValue="Female" itemLabel="Female" /></apex:selectRadio>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Hi here is the sample code for your asking for form submission.i have create custom object Registration_Forum__c.
Click to see Custom Object Registration_Forum__c Image
<apex:page Controller="VFFileUpload">
<apex:pageMessages id="showmsg"></apex:pageMessages>
<apex:form>
<apex:pageBlock title="Upload Attachment">
<apex:pageBlockButtons location="top">
<apex:commandButton value="Save" action="{!saveForm}" />
<apex:commandButton value="reset" action="{!resetForm}" />
</apex:pageBlockButtons>
<apex:pageBlockSection>
<apex:inputField value="{!Registration_Forum.Name}" />
<apex:inputField value="{!Registration_Forum.age__c}" />
<apex:inputField value="{!Registration_Forum.Certification__c}" />
<apex:inputField value="{!Registration_Forum.Project_Unit__c}" />
<apex:selectRadio value="{!Registration_Forum.Gender__c}">
<apex:selectOption itemValue="Male" itemLabel="Male" />
<apex:selectOption itemValue="Female" itemLabel="Female" />
</apex:selectRadio>
<apex:inputFile id="file" value="{!fileBody}" filename="{!fileName}" />
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
public class VFFileUpload
{
public Registration_Forum__c Registration_Forum{get;set;}
public String fileName {get;set;}
public Blob fileBody {get;set;}
public VFFileUpload() {
Registration_Forum=new Registration_Forum__c();
}
public void saveForm(){
upsert Registration_Forum;
if(fileBody != null && fileName != null && Registration_Forum.id!=null)
{
Attachment myAttachment = new Attachment();
myAttachment.Body = fileBody;
myAttachment.Name = fileName;
myAttachment.ParentId = Registration_Forum.Id;
upsert myAttachment;
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.info,'File Upload Success'));
}
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.info,'Form Submission Success'));
}
public void resetForm(){
Registration_Forum=new Registration_Forum__c();
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.info,'Reset'));
}
}

apex inputText value null in controller

I have an input filed that I am attempting to pass the end user's entered input into the SF controller class.
Below is the inputText visualforce code:
<div class="ssa-inputs">
<div class="ssa-input-text">Name: </div>
<div class="ssa-input">
<apex:form>
<apex:inputText value="{!acknowledgeInput}" id="acknowledgeInput"/>
</apex:form>
</div>
</div>
<div class="ssa-btns">
<div class="ssa-btn">
<apex:form>
<apex:commandButton id="acceptHidden" value="Accept" action="{!updatecontact}"/>
</apex:form>
<input type="submit" id="acceptBtn" value="Accept"/>
</div>
<div class="ssa-btn">
<apex:form>
<apex:commandButton value="Decline" action="{!updatecontact}"/>
</apex:form>
</div>
</div>
Below is the SF controller code:
public string acknowledgeInput{get;set;}
public PageReference updatecontact(){
System.debug(LoggingLevel.DEBUG, acknowledgeInput);
// Update contact information
// Redirect to respected PageReference
}
When I try to print out the value in the logs, I receive null.
I feel like this is pretty straight forward and I can't seem to find what I'm missing.
Thanks
You need to have the command button and input text field in the same form.

Using two actions on a single checkbox event

I am having problems while trying to render a pageblocksection in visualforce. The code that i have used is as given below.
<apex:pageBlockSection title="My Content Section" columns="2">
<apex:pageBlockSectionItem>
<apex:outputLabel value="Account Site"/>
<apex:outputPanel>
<apex:inputText value="{!account.site}" id="account__site"
onclick="changefont(this)">
<apex:actionSupport event="onclick"
rerender="thePageBlock" status="Status"/>
</apex:outputPanel>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
Here I am trying to render a page block and a javascript function at the same time, i,e the checking of a checkbox(Account Site). The problem here is when i try to execute the changefont(this) function in the onclick of apex:inputText and then try to render "thePageblock" in event="onclick" of apex:actionSupport the rendering does not take place. Is there a problem with my code or should i do this a different way.
Thanks..
Try calling your Javascript function from the onsubmit or oncomplete attribute of your apex:actionSupport tag:
<apex:inputText value="{!account.site}" id="account__site" >
<apex:actionSupport event="onclick" rerender="thePageBlock"
status="Status" onsubmit="changefont(this)" />
</apex:inputText>

Location attribute is not working for PageBlockButtons

I'm trying to use command buttons using a dynamic component. I want to render these command buttons on the bottom of the page but I'm not able to do it. when I use location=top, it works. when I use location=bottom, I can't see the buttons at all. When I use location=both, I see them only at the top. I'm not using any facets. Please help me if someone knows!
I used them using apex code.
This is the VF page:
<apex:page title="Opportunity Display" controller="MyPageController1" showHeader="true" sidebar="false" readOnly="true" cache="false" >
<apex:sectionHeader subtitle="SOQL Offset Example w/Dynamic Page Buttons" title="Opportunity Display Table" />
<apex:form >
<apex:pageBlock >
<apex:dynamicComponent componentValue="{!myCommandButtons}" />
<apex:actionFunction action="{!refreshGrid}" name="queryByPage" reRender="myPanel,myButtons" >
<apex:param name="firstParam" assignTo="{!selectedPage}" value="" />
</apex:actionFunction>
<apex:pageBlockSection title="Opportunity Display (Total List Size: {!total_size})" collapsible="false">
<apex:outputPanel id="myPanel">
<apex:pageMessages id="theMessages" />
<apex:pageBlockTable value="{!opportunity}" var="n" align="center">
<apex:column><apex:inputCheckbox value="{!n.checked}"/></apex:column>
<apex:column value="{!n.cat.Id}" />
<apex:column value="{!n.cat.Name}" />
<apex:facet name="footer">Showing Page # {!pageNumber} of {!totalPages}</apex:facet>
</apex:pageBlockTable>
</apex:outputPanel>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

How do I get a "New" button on my custom apex:pageBlockTable for Cases?

I have a custom Cases apex page where I use a apex:pageBlockTable to display my list of Cases. Here is the code for it:
<apex:page standardController="Case" recordSetVar="Case" sidebar="true" showHeader="true">
<apex:form >
<apex:pageBlock title="Cases">
<apex:outputLabel value="View:"/>
<apex:selectList value="{!filterId}" size="1">
<apex:actionSupport event="onchange" rerender="cases_table"/>
<apex:selectOptions value="{!listviewoptions}"/>
</apex:selectList>
<apex:pageBlock >
<apex:pageBlockButtons >
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!case}" var="c" rows="50" id="cases_table" >
<apex:column >
<a target="_parent" href="{!URLFOR($Action.Case.View, c.id)}">{!c.CaseNumber}</a>
<apex:facet name="header">Case Number</apex:facet>
</apex:column>
<apex:column value="{!c.ContactId}" />
<apex:column value="{!c.Subject}" />
<apex:column value="{!c.Status}" />
<apex:column value="{!c.Priority}" />
</apex:pageBlockTable>
</apex:pageBlock>
</apex:pageBlock>
</apex:form>
<base target="_parent"/>
</apex:page>
I would like to get a button inside my apex:pageBlockButtons like in the default Cases page. When the user clicks the button, I would like it to take the user to the new Cases page. I tried this:
<apex:commandButton action="{!new}" value="New"/>
but that gave me an error. How do I make a button that will take me to the new Cases page?
Try this:
<apex:commandButton onclick="window.location.href='{!URLFOR($Action.Case.NewCase)}'" value="New" immediate="true" rerender="blank"/>
Important to note that the rerender tag is needed otherwise the page will do a postback. By using a dummy rerender tag the redirect will work. Immediate is there to avoid running any validation rules on click.
I have a custom Cases apex page where I use a apex:pageBlockTable to display my list of Cases. Here is the code for it(custom object):
<apex:commandButton action="{!URLFOR($Action.Your_Custom_Object__c.New)}" ...>

Resources