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
vamsi krishna 106vamsi krishna 106 

Error Showing Read only Property while using the Wrapper class variable in VF

Hi Guys,
I am using Wrapper class varialbe in vf.It showing error :Read inoy Property..
 My wrapper class varibale declaration is 

public Date FromDateCriteria;
      Public  void setFromDateCriteria(Date FromDateCriteria) {
      this.FromDateCriteria = FromDateCriteria;
     }
   public string getFromDateCriteria() {
      if(FromDateCriteria==NULL){
       return NULL;
      }
    return FromDateCriteria.format();
    }

Please give me some solutions..
pconpcon
You are returning a String and you are setting from a Date.  So you need to change the input from Date to String
 
public Date fromDateCriteria;

public  void setFromDateCriteria(String fromDateCriteria) {
    this.fromDateCriteria = Date.parse(fromDateCriteria);
}

public string getFromDateCriteria() {
    return (fromDateCriteria == null) ? null : fromDateCriteria.format();
}

 
vamsi krishna 106vamsi krishna 106
"fromDateCriteria"  At VF i am getting " Unknown property "  error
vamsi krishna 106vamsi krishna 106
HI pcon,

Thanx for ur code  and it's working fine but i am getting "Unknown property" error at vf  for variable  of 

fromDateCriteria.  please give me some solution..please...
pconpcon
Can you please provide the Visualforce that you are using to call this variable?

NOTE: When including code please use the "Add a code sample" button (icon <>) to increase readability and make referencing code easier.
vamsi krishna 106vamsi krishna 106
VF 

<apex:repeat value="{!wraptissuesList}" var="tissue">
<apex:inputCheckbox value="{!tissue.isSelectedtissue}"  id="InputIdshipped" onClick="checkOne(this.value);"  />
 <apex:inputtext  id="implatedDate" size="10" value="{!tissue.implanteddate}"/>
</apex:repeat>

Class

 public class wrapTissues{
    public Tissue__c tissues{get;set;}//It's for tissues
    public boolean isSelectedTUR{get;set;}//It's for creating the TUR's 
    public boolean isSelectedtissue{get;set;}//It's for selecting the Implated tissues for billing
    public boolean Reorderselected{get;set;}//It's for Re-Order check box
    public boolean pricecheckselected{get;set;}//It's for Request for price check
    public Double  price{get;set;}//It's price of the product.
    Public Date implanteddate;
    Public Date formatdate{get;set;}
    Public void setimplanteddate(String implanteddate) {
     this.implanteddate= date.parse(implanteddate);
    }
   public String getimplanteddate() {
       return (implanteddate== null) ? null : implanteddate.format();
    }

     public wrapTissues(tissue__c t){
         tissues=t;
         isSelectedTUR=false;
         isSelectedtissue=false;
         Reorderselected=false;
         pricecheckselected=false;
         price=0;
      }
     }

Please give me some suggestions..
pconpcon
There is some missing code here.  So the following works correctly for me

PageWrapper.cls
public class PageWrapper {
    public List<InnerWrapper> wrappers {
        get;
        set;
    }
    
    public class InnerWrapper {
        public Date myDate;
        
        public InnerWrapper(Date myDate) {
            this.myDate = myDate;
        }
        
        public String getMyDate() {
            return (this.myDate == null) ? null : this.myDate.format();
        }
        
        public void setMyDate(String myDate) {
            this.myDate = Date.parse(myDate);
        }
    }
    
    public PageWrapper() {
        this.wrappers = new List<InnerWrapper>();
        
        for (Integer i = 1; i < 4; i++) {
            this.wrappers.add(new InnerWrapper(Date.parse('0' + i + '/0' + i + '/2015')));
        }
    }
    
    public PageReference doSave() { 
        return null;
    }
}

PageWrapper.vfp
<apex:page controller="PageWrapper">
    <apex:form>
        <apex:repeat value="{!wrappers}" var="wrapper">
            <div>
                <apex:inputText value="{!wrapper.myDate}" />
            </div>
        </apex:repeat>
        
        <apex:commandButton value="Save" action="{!doSave}" />
    </apex:form>
</apex:page>