You need to sign in to do that
Don't have an account?
DeepV
when clicked a button, able to edit. How to achieve it?
Hi All,
I have the following visualforce page, initially when the page loads the Role Field should be readonly. But when AddContact button is clicked then the Role field should be editable.
<apex:page standardcontroller="REL_VS_Submission__c" extensions="RELVSRenewalController" sidebar="false">
<apex:sectionheader title="VSA Renewal Submission" subtitle="Step 2 of 10" />
<apex:messages />
<apex:form >
<apex:pageblock title="Contact Information">
<apex:variable value="{!0}" var="rowContactNumber" />
<!-- Here we will use an extra variable to define a row number -->
<apex:outputpanel id="panelWithVar">
<apex:variable value="{!0}" var="rowContactNumber" />
</apex:outputpanel>
<apex:pageblocksection title="Contact Information" columns="1">
<apex:pageblocktable value="{!anewContact}" var="item" id="newContactitems" columnsWidth="5%,20%,10%,10%,10%,10%,5%,5%,5%,5%,10%,3%,2%">
<!-- A button to remove individual entry. s
We must to pass the line number to define a list entry number to remove -->
<apex:column headervalue="Delete">
<apex:commandbutton immediate="true" action="{!removeContactObject}" value=" X " rerender="newContactitems,panelWithVar">
<apex:param name="p2" value="{!rowContactNumber}" assignto="{!numberOfContactRowToRemove}" />
</apex:commandbutton>
</apex:column>
<!-- Moreover here we incrementing the row number variable -->
<!--<apex:column headerValue="RowCount">
<apex:outputText value="{!rowContactNumber}"/>
</apex:column>-->
<apex:column headervalue="Role">
<apex:inputfield value="{!item.REL_VS_Contact_Role__c}" disabled="{!isDisabled"/>
<apex:variable var="rowContactNumber" value="{!rowContactNumber + 1}" />
</apex:column>
<apex:column headervalue="First Name">
<apex:inputfield value="{!item.Firstname}" required="true" />
</apex:column>
<apex:column headervalue="Last Name">
<apex:inputfield value="{!item.Lastname}" required="true" />
</apex:column>
<apex:column headervalue="Phone">
<apex:inputfield value="{!item.Phone}" required="true" />
</apex:column>
<apex:column headervalue="Fax">
<apex:inputfield value="{!item.Fax}" required="true" />
</apex:column>
<apex:column headervalue="Personal Email">
<apex:inputfield value="{!item.Email}" required="true" />
</apex:column>
<apex:column headervalue="General Email" >
<apex:inputfield value="{!item.REL_VS_Generic_Email__c}" />
</apex:column>
<apex:column headervalue="Title">
<apex:inputfield value="{!item.Title}" required="true"/>
</apex:column>
<apex:column headervalue="Mailing Street">
<apex:inputfield value="{!item.MailingStreet}" required="true"/>
</apex:column>
<apex:column headervalue="Mailing City">
<apex:inputfield value="{!item.MailingCity}" required="true"/>
</apex:column>
<apex:column headervalue="Mailing State">
<apex:inputfield value="{!item.MailingState}" required="true" />
</apex:column>
<apex:column headervalue="Mailing Zip">
<apex:inputfield value="{!item.MailingPostalCode}" required="true" />
</apex:column>
</apex:pageblocktable>
</apex:pageblocksection>
<!-- A main button to add a new item -->
<apex:commandbutton value="Add Contact" action="{!addContactObject}" rerender="newContactitems,panelWithVar" immediate="true"/>
</apex:pageblock>
<apex:pageblock >
<apex:pageblocksection columns="4">
<apex:commandbutton action="{!step3}" value="Save and Continue"
styleclass="btn" />
<apex:commandbutton action="{!reset}" value="Reset Page"
styleclass="btn" immediate="true" />
<apex:commandbutton action="{!exit}" value="Exit"
styleclass="btn" immediate="true" />
<apex:commandbutton action="{!Back}" value="Back"
styleclass="btn" immediate="true" />
</apex:pageblocksection>
</apex:pageblock>
</apex:form>
</apex:page>
Apex code:
public Boolean isDisabled {get; set;}
//constructor
isDisabled = true;
public PageReference addContactObject() {
anewContact.add(new Contact(FirstName = ''));
//making it editable
isDisabled = false;
return null;
}
Please help me, the above code is failing for me.
I have the following visualforce page, initially when the page loads the Role Field should be readonly. But when AddContact button is clicked then the Role field should be editable.
<apex:page standardcontroller="REL_VS_Submission__c" extensions="RELVSRenewalController" sidebar="false">
<apex:sectionheader title="VSA Renewal Submission" subtitle="Step 2 of 10" />
<apex:messages />
<apex:form >
<apex:pageblock title="Contact Information">
<apex:variable value="{!0}" var="rowContactNumber" />
<!-- Here we will use an extra variable to define a row number -->
<apex:outputpanel id="panelWithVar">
<apex:variable value="{!0}" var="rowContactNumber" />
</apex:outputpanel>
<apex:pageblocksection title="Contact Information" columns="1">
<apex:pageblocktable value="{!anewContact}" var="item" id="newContactitems" columnsWidth="5%,20%,10%,10%,10%,10%,5%,5%,5%,5%,10%,3%,2%">
<!-- A button to remove individual entry. s
We must to pass the line number to define a list entry number to remove -->
<apex:column headervalue="Delete">
<apex:commandbutton immediate="true" action="{!removeContactObject}" value=" X " rerender="newContactitems,panelWithVar">
<apex:param name="p2" value="{!rowContactNumber}" assignto="{!numberOfContactRowToRemove}" />
</apex:commandbutton>
</apex:column>
<!-- Moreover here we incrementing the row number variable -->
<!--<apex:column headerValue="RowCount">
<apex:outputText value="{!rowContactNumber}"/>
</apex:column>-->
<apex:column headervalue="Role">
<apex:inputfield value="{!item.REL_VS_Contact_Role__c}" disabled="{!isDisabled"/>
<apex:variable var="rowContactNumber" value="{!rowContactNumber + 1}" />
</apex:column>
<apex:column headervalue="First Name">
<apex:inputfield value="{!item.Firstname}" required="true" />
</apex:column>
<apex:column headervalue="Last Name">
<apex:inputfield value="{!item.Lastname}" required="true" />
</apex:column>
<apex:column headervalue="Phone">
<apex:inputfield value="{!item.Phone}" required="true" />
</apex:column>
<apex:column headervalue="Fax">
<apex:inputfield value="{!item.Fax}" required="true" />
</apex:column>
<apex:column headervalue="Personal Email">
<apex:inputfield value="{!item.Email}" required="true" />
</apex:column>
<apex:column headervalue="General Email" >
<apex:inputfield value="{!item.REL_VS_Generic_Email__c}" />
</apex:column>
<apex:column headervalue="Title">
<apex:inputfield value="{!item.Title}" required="true"/>
</apex:column>
<apex:column headervalue="Mailing Street">
<apex:inputfield value="{!item.MailingStreet}" required="true"/>
</apex:column>
<apex:column headervalue="Mailing City">
<apex:inputfield value="{!item.MailingCity}" required="true"/>
</apex:column>
<apex:column headervalue="Mailing State">
<apex:inputfield value="{!item.MailingState}" required="true" />
</apex:column>
<apex:column headervalue="Mailing Zip">
<apex:inputfield value="{!item.MailingPostalCode}" required="true" />
</apex:column>
</apex:pageblocktable>
</apex:pageblocksection>
<!-- A main button to add a new item -->
<apex:commandbutton value="Add Contact" action="{!addContactObject}" rerender="newContactitems,panelWithVar" immediate="true"/>
</apex:pageblock>
<apex:pageblock >
<apex:pageblocksection columns="4">
<apex:commandbutton action="{!step3}" value="Save and Continue"
styleclass="btn" />
<apex:commandbutton action="{!reset}" value="Reset Page"
styleclass="btn" immediate="true" />
<apex:commandbutton action="{!exit}" value="Exit"
styleclass="btn" immediate="true" />
<apex:commandbutton action="{!Back}" value="Back"
styleclass="btn" immediate="true" />
</apex:pageblocksection>
</apex:pageblock>
</apex:form>
</apex:page>
Apex code:
public Boolean isDisabled {get; set;}
//constructor
isDisabled = true;
public PageReference addContactObject() {
anewContact.add(new Contact(FirstName = ''));
//making it editable
isDisabled = false;
return null;
}
Please help me, the above code is failing for me.