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
Meer SalmanMeer Salman 

events for output field or label

Hi..
I have a following PageBlock in my page. I wonder how can I acheive onchange event for output field and rerender another field when the value is changed?
In my case I have two custom fields Journal.Period__c and Journal.Journal_Date__c,  as you can see the PageBlock is in mode="inlineEdit" thus if I change the Journal.Period__c value i want to change the value for Journal.Journal_Date__c  accordingly. I have use <apex:inputField> tag to acheive my target but it doesn't give a nice look to the page so I was looking something like onchange event for <apex:outfield> or  <apex:outlabel> etc.
<apex:pageBlock mode="inlineEdit" title="Journal Detail">
        <apex:pageBlockSection columns="2">
            <apex:inputField id="period_date" value="{!Journal.Period__c}" onchange="ShowJournalDate(this)"/>
            <apex:outputLabel />
            <apex:inputField id="journal_date" value="{!Journal.Journal_Date__c}"/>
            <apex:outputLabel />
            <apex:outputField value="{!Journal.Card__c}"/>
            <apex:outputLabel ></apex:outputLabel>
            <apex:outputField value="{!Journal.Description__c}"/>        
        </apex:pageBlockSection>
</apex:pageBlock>
I wish there must be some solution for what I am looking for.
Regards,
Meer Salman
Naidu PothiniNaidu Pothini
<apex:actionSupport event="onChange" action="{!doSomething}" rerender=" something"/>

 

Did you try using ActionSupport? if not try and let me know if you are not able to fix this.

Meer SalmanMeer Salman

I tried something like below:

 

I made some changes in my Extension and VFPage as given below:

 

 

*****Controller*****


 //Function for Journal Date
 public PageReference ShowJournalDate() 
     {
         Fin_Periods__c period = [SELECT PrdStDate__c FROM Fin_Periods__c WHERE Name =: Journal.Period__c];
         Journal.Journal_Date__c = period.PrdStDate__c;
         return null;         
     }

 

 

*****VFPage***** 

<apex:pageBlock mode="inlineEdit" title="Journal Detail">
        <apex:pageBlockSection columns="2">
            <apex:actionSupport event="onChange" action="{!ShowJournalDate}" rerender="journal_date">
                <apex:outputField id="period_date" value="{!Journal.Period__c}"/>
            </apex:actionSupport>                                 
            <apex:outputLabel />
            <apex:outputField id="journal_date" value="{!Journal.Journal_Date__c}"/>
            <apex:outputLabel />
            <apex:outputField value="{!Journal.Card__c}"/>
            <apex:outputLabel ></apex:outputLabel>
            <apex:outputField value="{!Journal.Description__c}"/>        
        </apex:pageBlockSection>
    </apex:pageBlock>
Its not setting the date, beside in layout the field title for Journal.Period__c is gone and the field itself is align on the left most side. Hmmmm not so good :(
Naidu PothiniNaidu Pothini
<apex:pageBlock mode="inlineEdit" title="Journal Detail">
        <apex:pageBlockSection columns="2">
            
            <apex:outputField id="period_date" value="{!Journal.Period__c}">
                <apex:actionSupport event="onChange" action="{!ShowJournalDate}" rerender="journal_date"/>
            </apex:outputField>                                 
            <apex:outputLabel />
            <apex:outputField id="journal_date" value="{!Journal.Journal_Date__c}"/>
            <apex:outputLabel />
            <apex:outputField value="{!Journal.Card__c}"/>
            <apex:outputLabel ></apex:outputLabel>
            <apex:outputField value="{!Journal.Description__c}"/>        
        </apex:pageBlockSection>
    </apex:pageBlock>

 

 

Try this and let me know if it doesnt work.

Meer SalmanMeer Salman

Sorry still not working. Well I belive <apex:outputfield> doesn't have the events associated with it therefore <apex:actionsupport> event  tag doesn't fire. I guess <apex:actionsupport> will only work with those components which have their own event handlers.I doubt I am right.

 

Regards,

Meer Salman