You need to sign in to do that
Don't have an account?
sfg1
Field readonly after clicking save button in visualforce page
I have long text area Text field 'comments__c', after entering data in comments__c text box and click on save, comment field should be read only I tried below code, but it is not working as expected. I need to display that page in SITE.please guide me.
Controller:
public class CampaignRecordIdController{
public String campaignRecordId {get;set;}
public String parameterValue {get;set;}
public Campaign cam{get;set;}
public boolean rend{get;set;}
public boolean rend1{get;set;}
public Campaign Campaign{get;set;}
public CampaignRecordIdController()
{
campaignRecordId =ApexPages.currentPage().getParameters().get('id');
system.debug('=====campaignRecordId ===='+campaignRecordId);
cam = [select name,Promotion_Details__c,parentid,Comments__C from Campaign member where id =: campaignRecordId ];
rend=true;
rend1=false;
}
public PageReference save() {
update cam;
rend=false;
rend1=true;
return null;
}
}
Page:
<apex:page Controller="CampaignRecordIdController" sidebar="false" showheader="false">
<apex:form >
<apex:pageBlock>
<apex:pageBlockSection title="Current Campaign record Id is : {!campaignRecordId}" collapsible="false" columns="1" rendered="{!rend}">
<apex:outputField value="{!cam.name}"/>
<apex:outputField value="{!cam.Promotion_Details__c}"/>
<apex:outputField value="{!cam.Parentid}"/>
<apex:inputtext value="{!cam.Comments__c}" style="width: 360px; height: 40px"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Current Campaign record Id is : {!campaignRecordId}" collapsible="false" columns="1" rendered="{!rend1}">
<apex:outputField value="{!cam.name}"/>
<apex:outputField value="{!cam.Promotion_Details__c}"/>
<apex:outputField value="{!cam.Parentid}"/>
<apex:outputfield value="{!cam.Comments__c}" style="width: 360px; height: 40px"/>
</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="save"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller:
public class CampaignRecordIdController{
public String campaignRecordId {get;set;}
public String parameterValue {get;set;}
public Campaign cam{get;set;}
public boolean rend{get;set;}
public boolean rend1{get;set;}
public Campaign Campaign{get;set;}
public CampaignRecordIdController()
{
campaignRecordId =ApexPages.currentPage().getParameters().get('id');
system.debug('=====campaignRecordId ===='+campaignRecordId);
cam = [select name,Promotion_Details__c,parentid,Comments__C from Campaign member where id =: campaignRecordId ];
rend=true;
rend1=false;
}
public PageReference save() {
update cam;
rend=false;
rend1=true;
return null;
}
}
Page:
<apex:page Controller="CampaignRecordIdController" sidebar="false" showheader="false">
<apex:form >
<apex:pageBlock>
<apex:pageBlockSection title="Current Campaign record Id is : {!campaignRecordId}" collapsible="false" columns="1" rendered="{!rend}">
<apex:outputField value="{!cam.name}"/>
<apex:outputField value="{!cam.Promotion_Details__c}"/>
<apex:outputField value="{!cam.Parentid}"/>
<apex:inputtext value="{!cam.Comments__c}" style="width: 360px; height: 40px"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Current Campaign record Id is : {!campaignRecordId}" collapsible="false" columns="1" rendered="{!rend1}">
<apex:outputField value="{!cam.name}"/>
<apex:outputField value="{!cam.Promotion_Details__c}"/>
<apex:outputField value="{!cam.Parentid}"/>
<apex:outputfield value="{!cam.Comments__c}" style="width: 360px; height: 40px"/>
</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="save"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
All Answers
Try this code.
Hope this helps.
public boolean disabled{get;set;}
public CampaignRecordIdController()
{
disabled=false;
campaignRecordId =ApexPages.currentPage().getParameters().get('id');
system.debug('=====campaignRecordId ===='+campaignRecordId);
cam = [select name,Promotion_Details__c,parentid,Comments__C from Campaign member where id =: campaignRecordId ];
rend=true;
rend1=false;
if(cam.Comments__C.length>2){
disabled=true;
}
}
<div class="requiredinput">
<div class="requiredBlock"></div>
<apex:inputfield value="{!cam.Comments__c}" required="true" style="width: 360px; height: 40px"/>
</div>
Now i need to check condition, if 'status=Deny' in 'Campaignmember', second time i should not allow them to enter comments in field(Comments--C) . It sholud through error like 'Already comments entered'. I tried for checking condition in contstructor, but i am getting error.pls guide me.
Class
public class CampaignRecordIdController{
public String campaignRecordId {get;set;}
public campaignmember cam{get;set;}
public boolean rend{get;set;}
public boolean rend1{get;set;}
public boolean disabled{get;set;}
public string Campaignmemberid {get;set;}
public CampaignRecordIdController()
{
campaignRecordId = System.currentPageReference().getParameters().get('id');
system.debug('=====campaignRecordId ===='+campaignRecordId);
Cam = [select name,Promotion_Details__c,Comments__C,campaignid from Campaignmember where id =: campaignRecordId ];
rend=true;
rend1=false;
}
public PageReference save() {
update cam;
rend=false;
rend1=true;
return null;
}
}
Page
<apex:page Controller="CampaignRecordIdController" sidebar="false" showheader="false">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection title="Current Campaign record Id is : {!campaignRecordId}" collapsible="false" columns="1" rendered="{!rend}">
<apex:outputField value="{!cam.name}"/>
<apex:outputField value="{!cam.Promotion_Details__c}"/>
<apex:outputField value="{!cam.campaignid}"/>
<div class="requiredinput">
<div class="requiredBlock"></div>
<apex:inputfield value="{!cam.Comments__c}" required="true" style="width: 360px; height: 40px"/>
</div>
</apex:pageBlockSection>
<apex:pageBlockSection title="Current Campaign record Id is : {!campaignRecordId}" collapsible="false" columns="1" rendered="{!rend1}">
<apex:outputField value="{!cam.name}"/>
<apex:outputField value="{!cam.Promotion_Details__c}"/>
<apex:outputField value="{!cam.campaignid}"/>
<apex:outputfield value="{!cam.Comments__c}" style="width: 360px; height: 40px"/>
</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="save"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>