• Santosh Tripathy
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
I have a pretty simple use case, where i dont want to show a field on visualforce page if certain criteria is satisfied. I use the redered attribute for that and it works fine. But when i try to capture the value from the input field in controller, it comes as null even though i selected the value on VF page. If i take out the rendered attribute and the field is shown all the time, there is no issue and i am able to capture the value correctly. Refer to the field New_Project_or_Add_on_Revenue__c in the following code where this issue is coming. Anything going wrong here?

<apex:form id="form">
        <apex:pageBlock title="Create a new opportunity" >
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Next" action="{!save}" reRender="form,errors" />
            </apex:pageBlockButtons> 
        
            <apex:pageMessages id="errors"/>
            
            <apex:pageBlockSection columns="1"  >                
               <!--Using Record types. No Longer using Service-Provider-Related (CSG) Opportunity? Picklist (ServiceProviderSellThroughOpp__c). Using Record Type Radio Button instead : Below line added by Satish Danda. -->
                <apex:selectRadio value="{!SelectedRecordTypeID}" label="Record Type" layout="pageDirection" >
                    <apex:SelectOptions value="{!RecordTypes}" />
                    <apex:actionSupport event="onchange" action="{!ChangeCSGServiceProvider}" reRender="form"/>
                </apex:selectRadio>


                 <!--<apex:pageBlockSectionItem rendered="{!IF(SelectedRecordTypeID == '01240000000IVXwAAO',true,false)}" id="endCustBlock">-->
                <apex:pageBlockSectionItem rendered="{!renderEndCustomer}" id="endCustBlock">
                    <apex:outputLabel id="endCustId" value="End User Customer "/>
                    <apex:inputField id="endUserCustomerIF" value="{!Opportunity.EndUserCustomerAccountId__c}" style="width: 80%"/>

                </apex:pageBlockSectionItem>
                 <!--<apex:outputPanel id="wrapperPannel" layout="none">
                 <apex:pageBlockSection columns="1"  rendered="{!IF(SelectedRecordTypeID == '01240000000IVXwAAO',true,false)}">                                                         
                            <apex:inputField id="endUserCustomerIF" value="{!Opportunity.EndUserCustomerAccountId__c}" style="width: 80%"/>                                          
                    </apex:pageBlockSection>
                    
                </apex:outputPanel>-->    
                
                <apex:pageBlockSectionItem >
                    <apex:outputLabel id="accName" value="{!IF(SelectedRecordTypeID == '01240000000IVXwAAO','Service Provider','Account')}" />
                    <apex:inputField id="account" value="{!Opportunity.AccountId}" style="width: 80%" />
                </apex:pageBlockSectionItem>
                
                <apex:inputField value="{!Opportunity.Name}" required="false" style="width: 80%">
                    <apex:actionSupport event="onfocus" reRender="OpenOppts" action="{!populateOppts}"/>
                </apex:inputField>
                <apex:inputField value="{!Opportunity.CloseDate}"/> 
                <apex:inputField value="{!Opportunity.DealBroughtBy__c}" id="dealbroughtby" />
                <apex:inputfield id="newOrAddonIDVal" value="{!Opportunity.New_Project_or_Add_on_Revenue__c}" rendered="{!renderNewOrAddOn}" />

                
            </apex:pageBlockSection>
I have a pretty simple use case, where i dont want to show a field on visualforce page if certain criteria is satisfied. I use the redered attribute for that and it works fine. But when i try to capture the value from the input field in controller, it comes as null even though i selected the value on VF page. If i take out the rendered attribute and the field is shown all the time, there is no issue and i am able to capture the value correctly. Refer to the field New_Project_or_Add_on_Revenue__c in the following code where this issue is coming. Anything going wrong here?

<apex:form id="form">
        <apex:pageBlock title="Create a new opportunity" >
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Next" action="{!save}" reRender="form,errors" />
            </apex:pageBlockButtons> 
        
            <apex:pageMessages id="errors"/>
            
            <apex:pageBlockSection columns="1"  >                
               <!--Using Record types. No Longer using Service-Provider-Related (CSG) Opportunity? Picklist (ServiceProviderSellThroughOpp__c). Using Record Type Radio Button instead : Below line added by Satish Danda. -->
                <apex:selectRadio value="{!SelectedRecordTypeID}" label="Record Type" layout="pageDirection" >
                    <apex:SelectOptions value="{!RecordTypes}" />
                    <apex:actionSupport event="onchange" action="{!ChangeCSGServiceProvider}" reRender="form"/>
                </apex:selectRadio>


                 <!--<apex:pageBlockSectionItem rendered="{!IF(SelectedRecordTypeID == '01240000000IVXwAAO',true,false)}" id="endCustBlock">-->
                <apex:pageBlockSectionItem rendered="{!renderEndCustomer}" id="endCustBlock">
                    <apex:outputLabel id="endCustId" value="End User Customer "/>
                    <apex:inputField id="endUserCustomerIF" value="{!Opportunity.EndUserCustomerAccountId__c}" style="width: 80%"/>

                </apex:pageBlockSectionItem>
                 <!--<apex:outputPanel id="wrapperPannel" layout="none">
                 <apex:pageBlockSection columns="1"  rendered="{!IF(SelectedRecordTypeID == '01240000000IVXwAAO',true,false)}">                                                         
                            <apex:inputField id="endUserCustomerIF" value="{!Opportunity.EndUserCustomerAccountId__c}" style="width: 80%"/>                                          
                    </apex:pageBlockSection>
                    
                </apex:outputPanel>-->    
                
                <apex:pageBlockSectionItem >
                    <apex:outputLabel id="accName" value="{!IF(SelectedRecordTypeID == '01240000000IVXwAAO','Service Provider','Account')}" />
                    <apex:inputField id="account" value="{!Opportunity.AccountId}" style="width: 80%" />
                </apex:pageBlockSectionItem>
                
                <apex:inputField value="{!Opportunity.Name}" required="false" style="width: 80%">
                    <apex:actionSupport event="onfocus" reRender="OpenOppts" action="{!populateOppts}"/>
                </apex:inputField>
                <apex:inputField value="{!Opportunity.CloseDate}"/> 
                <apex:inputField value="{!Opportunity.DealBroughtBy__c}" id="dealbroughtby" />
                <apex:inputfield id="newOrAddonIDVal" value="{!Opportunity.New_Project_or_Add_on_Revenue__c}" rendered="{!renderNewOrAddOn}" />

                
            </apex:pageBlockSection>
I have a pretty simple use case, where i dont want to show a field on visualforce page if certain criteria is satisfied. I use the redered attribute for that and it works fine. But when i try to capture the value from the input field in controller, it comes as null even though i selected the value on VF page. If i take out the rendered attribute and the field is shown all the time, there is no issue and i am able to capture the value correctly. Refer to the field New_Project_or_Add_on_Revenue__c in the following code where this issue is coming. Anything going wrong here?

<apex:form id="form">
        <apex:pageBlock title="Create a new opportunity" >
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Next" action="{!save}" reRender="form,errors" />
            </apex:pageBlockButtons> 
        
            <apex:pageMessages id="errors"/>
            
            <apex:pageBlockSection columns="1"  >                
               <!--Using Record types. No Longer using Service-Provider-Related (CSG) Opportunity? Picklist (ServiceProviderSellThroughOpp__c). Using Record Type Radio Button instead : Below line added by Satish Danda. -->
                <apex:selectRadio value="{!SelectedRecordTypeID}" label="Record Type" layout="pageDirection" >
                    <apex:SelectOptions value="{!RecordTypes}" />
                    <apex:actionSupport event="onchange" action="{!ChangeCSGServiceProvider}" reRender="form"/>
                </apex:selectRadio>


                 <!--<apex:pageBlockSectionItem rendered="{!IF(SelectedRecordTypeID == '01240000000IVXwAAO',true,false)}" id="endCustBlock">-->
                <apex:pageBlockSectionItem rendered="{!renderEndCustomer}" id="endCustBlock">
                    <apex:outputLabel id="endCustId" value="End User Customer "/>
                    <apex:inputField id="endUserCustomerIF" value="{!Opportunity.EndUserCustomerAccountId__c}" style="width: 80%"/>

                </apex:pageBlockSectionItem>
                 <!--<apex:outputPanel id="wrapperPannel" layout="none">
                 <apex:pageBlockSection columns="1"  rendered="{!IF(SelectedRecordTypeID == '01240000000IVXwAAO',true,false)}">                                                         
                            <apex:inputField id="endUserCustomerIF" value="{!Opportunity.EndUserCustomerAccountId__c}" style="width: 80%"/>                                          
                    </apex:pageBlockSection>
                    
                </apex:outputPanel>-->    
                
                <apex:pageBlockSectionItem >
                    <apex:outputLabel id="accName" value="{!IF(SelectedRecordTypeID == '01240000000IVXwAAO','Service Provider','Account')}" />
                    <apex:inputField id="account" value="{!Opportunity.AccountId}" style="width: 80%" />
                </apex:pageBlockSectionItem>
                
                <apex:inputField value="{!Opportunity.Name}" required="false" style="width: 80%">
                    <apex:actionSupport event="onfocus" reRender="OpenOppts" action="{!populateOppts}"/>
                </apex:inputField>
                <apex:inputField value="{!Opportunity.CloseDate}"/> 
                <apex:inputField value="{!Opportunity.DealBroughtBy__c}" id="dealbroughtby" />
                <apex:inputfield id="newOrAddonIDVal" value="{!Opportunity.New_Project_or_Add_on_Revenue__c}" rendered="{!renderNewOrAddOn}" />

                
            </apex:pageBlockSection>
Hi,

here is my code for a Custom Component which i'm creating for inserting a DatePicker Control in VF page:
Code:
<apex:component >
 <apex:attribute name="pickDateLabel" description="This is the value for the label to display before pickdate component." type="String" required="true"/>
 <apex:attribute name="pickDateField" description="This is ID value of the Field to be used for component." type="String" required="true"/>
 <apex:attribute name="defaultValue" description="This is value of the Field." type="String" required="false"/>
 
 <SCRIPT src="{!URLFOR($Resource.jQuery_UI_DatePicker,'/ui.datepicker/jquery-1.2.6.min.js')}" type="text/javascript" />
 <apex:stylesheet value="{!URLFOR($Resource.jQuery_UI_DatePicker,'/ui.datepicker/smoothness/ui.datepicker.css')}" />
 <SCRIPT src="{!URLFOR($Resource.jQuery_UI_DatePicker,'/ui.datepicker/ui.datepicker.js')}" type="text/javascript" />

 <span style="font-weight:bold;text-align:right;">{!pickDateLabel}:&nbsp;</span>
 <input name="{!pickDateField}" id="{!pickDateField}" value="{!defaultValue}" style="font-size:12px;width:80px;" />
 <apex:inputText id="datePicker" value="{!defaultValue}" style="font-size:12px;width:80px;"></apex:inputText>

 <script type="text/javascript">
  $(document).ready(function(){
   $("#{!pickDateField}").datepicker({ 
       showOn: "both", 
       buttonImage: "{!URLFOR($Resource.jQuery_UI_DatePicker,'/calendar.dp.png')}", 
       buttonImageOnly: true,
       buttonText: "Pick date",
       dateFormat: 'mm/dd/yy'
   });
   $("#{!$Component.datePicker}").datepicker({ 
       showOn: "both", 
       buttonImage: "{!URLFOR($Resource.jQuery_UI_DatePicker,'/calendar.dp.png')}", 
       buttonImageOnly: true,
       buttonText: "Pick date",
       dateFormat: 'mm/dd/yy'
   });
  });
 </script>
 
</apex:component>

 
I use it in VF page using this:
Code:
<c:jQueryPickDate pickDateLabel="From" pickDateField="frmDate" defaultValue="{!frmDate}" />

 
Now, there are 2 textboxes shown on VF page where i use the Component, 1st One is Simple HTMl control, and is very nicely parsed by jQuery and a Date pick Calendar is shown on the Image lying adjacent to first textbox.

The 2nd one is Apex:InpuetTExt control, and is Not parsed by jQuery, and the Calendar is not shown for this control.

This is the HTML shown in Firefox on VF page load:
Code:
<span id="thePage:theForm:pageBlockFilter:j_id8">
 <script type="text/javascript" src="/resource/1228293028000/jQuery_UI_DatePicker/ui.datepicker/jquery-1.2.6.min.js"/>
 <script type="text/javascript" src="/resource/1228293028000/jQuery_UI_DatePicker/ui.datepicker/ui.datepicker.js"/>

 <span style="font-weight: bold; text-align: right;">From: </span>
 <input value="" style="font-size: 12px; width: 80px;" name="frmDate" id="frmDate" class="hasDatepicker"/><img align="absbottom" class="ui-datepicker-trigger" src="/resource/1228293028000/jQuery_UI_DatePicker/calendar.dp.png" alt="Pick date" title="Pick date"/>
 <input type="text" style="font-size: 12px; width: 80px;" name="thePage:theForm:pageBlockFilter:j_id8:j_id9:datePicker" id="thePage:theForm:pageBlockFilter:j_id8:j_id9:datePicker"/>

 <script type="text/javascript">
  $(document).ready(function(){
   $("#frmDate").datepicker({ 
       showOn: "both", 
       buttonImage: "/resource/1228293028000/jQuery_UI_DatePicker/calendar.dp.png", 
       buttonImageOnly: true,
       buttonText: "Pick date",
       dateFormat: 'mm/dd/yy'
   });
   $("#thePage:theForm:pageBlockFilter:j_id8:j_id9:datePicker").datepicker({ 
       showOn: "both", 
       buttonImage: "/resource/1228293028000/jQuery_UI_DatePicker/calendar.dp.png", 
       buttonImageOnly: true,
       buttonText: "Pick date",
       dateFormat: 'mm/dd/yy'
   });
  });
 </script>
 
</span>

 
Just check that ID passed in jQuery Javascript function is CORRECT one and still no Calendar associated with i2nd textbox :(.

please help.
  • December 03, 2008
  • Like
  • 0