0

I have a VF page that combines Contact, Account, Asset and related information to assist with Case entry. Our Assets contain Part Numbers, Serial Numbers and other information, but do not include the 'common names' that are often used to refer to them.

I created a utility class called FriendlyAsset() that uses the Part Number to generate the common name, and I'm trying to display that in my page. I pass the retrieved Asset(s) in and then (try to) use the new List<> to display the common name in my helper page.

The class is public as are the properties, but when I try to reference them in the page I get a "Compilation error: Unknown property 'Utils.FriendlyAsset.assetName'" error.

    public class FriendlyAsset {
      public String partNumber;
      public String serialNumber;
      public String assetName;

    // partNumber = IFS Part Number/Asset.Name, serialNumber = Serial Number
    // assetName includes the description
    public FriendlyAsset(Asset a) {
        this.partNumber = a.Name;
        this.SerialNumber = a.SerialNumber;

        if(this.partNumber == 'foo1') {
              this.assetName = 'Basic widget (foo1)';
          } else if(this.partNumber == 'foo2') {
              this.assetName = 'Enhanced widget (foo2)';                
          } else if(this.partNumber == 'foo3') {
              this.assetName = 'Boss widget (foo3)';                
          }
      }
}

In the page, I'm using a repeat to display the details:

    <apex:repeat var="fAsset" value="{!friendlyAssets}">
        <div class="stronglabel">{!fAsset.assetName}</div>&nbsp;&nbsp;
        <apex:outputText value="{!fAsset.serialNumber}" /><br />
    </apex:repeat>  <!-- well, I would, except that the '.' syntax fails to compile -->

I can display a value with <outputText value="{!fAsset}" />, which results in an output that looks like this:

FriendlyAsset:[assetName=Basic widget (foo1), partNumber=foo1, serialNumber=8005004]

So the details are in there, but I can't figure out how to access them.

Suggestions..?

5

Because you are referencing these in a VF page, the variables need to have getters

  public String partNumber   {get; private set;}
  public String serialNumber {get; private set;}
  public String assetName    {get; private set;}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.