1

i have an object (id, name, isvalid(default 0)) , there is 10 record in this object

i am trying to display all records (name) in visualforce page , in apex class i got all the records. but facing error to display in visual force page.

my apex class

public class PmQc {

    public List <String> urls;
    public List<String> getUrls()
    {
        urls =  new  List<String>();
       // System.debug('hello wors!!!!');
        for(CrawleLink__c cl :[select CrawleURL__c from CrawleLink__c])
        {
            System.debug('---'+cl.CrawleURL__c);
            urls.add(cl.CrawleURL__c);
        }
        return urls;
    }
}

my visualforce page

<apex:page controller="PmQc">
    <apex:form>
        <apex:pageBlock title="apple">
            <apex:pageBlockTable var="pq" value="{!PmQc}">
                <apex:column headerValue="URL">
                    <apex:inputField value="{!pq.urls}" label="URL"/>
                </apex:column>
                <apex:column headerValue="Is Valid">
                     <apex:inputCheckbox id="Isvalid" />
                </apex:column>
            </apex:pageBlockTable>
            <apex:commandButton value="update" action="update"/>
        </apex:pageBlock>

    </apex:form>
</apex:page>

now the error is

Unknown property 'PmQc.PmQc'

2 Answers 2

1

If your intent is to make the data editable, exposing the record list as a controller property is usually the simplest approach:

public class PmQc {
    public List<CrawleLink__c> links {get; private set;}
    public PmQc() {
        links = [
                select Id, Name, CrawleURL__c, IsValid__c
                from CrawleLink__c
                order by CrawleURL__c
                ];
    }
    public PageReference doUpdate() {
        update links;
        return null;
    }
}

so the Visualforce can then be:

        <apex:pageBlockTable var="link" value="{!links}">
            <apex:column headerValue="URL">
                <apex:inputField value="{!link.CrawleURL__c}" label="URL"/>
            </apex:column>
            <apex:column headerValue="Is Valid">
                 <apex:inputCheckbox value="{!link.IsValid__c}" id="Isvalid" />
            </apex:column>
        </apex:pageBlockTable>
        <apex:commandButton value="Update" action="{!doUpdate}"/>
1

public List urls{get;set;}
you need to add get,set prperty so that apex variable is accessible in VF.

In you apex:pagetable iterate urls variable, that is, apex:pageBlockTable var="pq" value="{!urls}"

And finally use CrawleURL__c reference to get the url apex:inputField value="{!pq.CrawleURL__c}" label="URL"

This should make your code run.

2
  • i wrote my all logic in getUrls method, (no need for set because i am not retrieving value from visualforce or any other class)
    – Prade jo
    May 29, 2016 at 14:27
  • Ohh I missed that. Please just iterate through urls variable. Bolded in previous answer.
    – Shankish
    May 29, 2016 at 15:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .