• springdev
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies

I have a use case where I need to do some string substitution on a string that has brace characters {}.  What is the proper way to escape the braces to make this test pass?

 

    public static testMethod void StringFormatFailsWithBraces()
    {
        List<string> substitutions = new List<String>();
        substitutions.add('world');
        string result = string.format('{hello {0}}', substitutions);
        System.assertEquals('{hello world}', result);
    }

 

Below is the very interesting exception which leads to demo.icu-project.org, which doesn't tell me any information.


System.StringException: All argument identifiers have to be either non-negative numbers or strings following the pattern ([:ID_Start:] [:ID_Continue:]*).
For more details on these unicode sets, visit http://demo.icu-project.org/icu-bin/ubrowse

 

Thanks!

 

Matt

So here's my problem:

 

I have a VisualForce component that I want to be able to drop onto any page layout (Account, Contact, Opportunity, etc).  My component doesn't need anything except for an id and a type, so it can be used on page layout.

 

So I have this one VisualForce page.  I only need this one VF page, because as I said, generic code.  However, in order for it to show up in the layout for the page, I find that I need to have a different VisualForce page for each type, with <apex:page standardController="Account"> set appropriately on each page.

 

So now I have ~10 pages that are all the same except the value of the standardController attribute, but it works.

 

Now I package up my code, and I include all of these pages.  It deploys just fine to a full salesforce.com account.  However, if I try to deploy it to a force.com account (which has only Account and Contact, and doesn't have Lead, Opportunity, etc, etc) it fails because there are VisualForce pages that reference those types, but those types are not configured for that organization.

 

I don't particularly care -- I want them to be able to install anyway, even if they don't have those types.  But I simply cannot find a way to make this work.

 

So, my questions:

 

#1. Is this the proper way of adding a generic VisualForce page to any layout, or is there an easier way of doing it than creating a different copy per object type?

 

#2. Is there a way to add VisualForce pages to a package conditionally, or mark them as optional, or otherwise not fail to deploy to an organization that doesn't have all the types?

I have a use case where I need to do some string substitution on a string that has brace characters {}.  What is the proper way to escape the braces to make this test pass?

 

    public static testMethod void StringFormatFailsWithBraces()
    {
        List<string> substitutions = new List<String>();
        substitutions.add('world');
        string result = string.format('{hello {0}}', substitutions);
        System.assertEquals('{hello world}', result);
    }

 

Below is the very interesting exception which leads to demo.icu-project.org, which doesn't tell me any information.


System.StringException: All argument identifiers have to be either non-negative numbers or strings following the pattern ([:ID_Start:] [:ID_Continue:]*).
For more details on these unicode sets, visit http://demo.icu-project.org/icu-bin/ubrowse

 

Thanks!

 

Matt