You need to sign in to do that
Don't have an account?
Disable the check box which is in component when I click the save button on vf page
Hi All,
I have one component(testcomponent) which is having a check box like sample below
<apex:component controller="test" id="check">
<apex:inputCheckbox value={}" id="bopt" />
</apex:component>
And one Vf Page which has the component in it and also one save button like
<apex:page controller="test1" id="pid">
<apex:commandButton value=" Save" title="Save Entire Page" />
<c:testcomponent>
</apex:page>
I need to disable the check box if it already been checked when page is loaded.
this i have done using the java script function
below function is working fine , it disabling the check box when the page is loading.
function disableCheckBox(){
if({!accountDetail.OptOutSettings.brandOptOut==true} ){
document.getElementById('{!$Component.check.bopt}').disabled=true;
}
else{
document.getElementById('{!$Component.check.bopt}').disabled=false;
}
}
Function was called in document ready state
$(document).ready(function() {
disableCheckBox();
}
but when i click save button on VF page checkbox is enabling again and also lost the previous data.
Can anyone suggest how to disable the check box which is in component when I click the save button on vf page.
Thank you
Off the top of my head.... create a custom controller for that component that has a value of
boolean isDisabled;
Set this value inside of the constructor and when the save button gets clicked
<apex:inputCheckbox value={}" id="bopt" disabled="{!isDisabled}" />
When the checkbox is clicked, also set 'isDisabled = true;' in your controller.
This is the first solution that came to mind, I'm sure there might be cleaner ways.
Hi Damine,
How to check whether check box is selected or in controller.
Mean your saying set 'isDisabled = true when check box is clicked. how to check wheter check box is selectd or not in controller.
Thank you
Build a wrapper class to put this into. Somethign similar to:
public class OuterClass
{
public List<InnerWrapper> someList;{get;private set;}
...//standard stuff
public class InnerWrapper
{
public sObject someObj{get;set;}
public boolean isDisabled{get;set;}
public InnerWrapper(SObject someObj)
{
this.someObj = someObj;
}
}
}
Hi Damine,
Thank you so much for the replay.
I solved my problem to day just ihave metion as you send like on check box
<ape:inputcheckbox disable={!IF(my business condition,true,false)}/>
Thank you
O Ok, that works. You could simplify that line to:
<apex:inputcheckbox disable="{!my business condition}" />
Hi Damie
I think you can help me here. I want to disable a check box. My vf page gets document list from a website And it has checkboxes. I want to disable the check box if in my documentlist "Internal Only' value is True.
Here is my VF Page
Please help
Currently... I'm locked out of my name.
Made my day Big time