• Superdome-old
  • NEWBIE
  • 53 Points
  • Member since 2013

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

Hi,

 

I need to be able to print cards that have someone's name and whatnot else on it. I already have a VF page for inputting this information. I would like to be able to dynamically create a VF page from the controller in the original VF page that gathers the correct info, open the newly created VF page so that the user can see it while at the same time bringing up the print dialogue via a javascript call in the header. My current attempt at this from what I have managed to find online looks as follows:

 

public PageReference createCard(String name, String company, String title)
    {
        Component.Apex.Page card = new Component.Apex.Page();
        Component.Apex.Form form = new Component.Apex.Form();
        Component.Apex.OutputLabel visitorName = new Component.Apex.OutputLabel();
        Component.Apex.OutputLabel visitorCompany = new Component.Apex.OutputLabel();
        Component.Apex.OutputLabel visitorTitle = new Component.Apex.OutputLabel();

        visitorName.value='name';
        visitorName.style='text-align:center; font-size:24pt;';
        
        visitorCompany.value='name';
        visitorCompany.style='text-align:center; font-size:24pt;';
        
        visitorTitle.value='name';
        visitorTitle.style='text-align:center; font-size;24pt;';
        
        form.childComponents.add(visitorName);
        form.childComponents.add(visitorCompany);
        form.childComponents.add(visitorTitle);
        
        //Stop point
        
        return null;
    }

 

At this point I am stuck. Since the page object does not have a childComponents field, I'm not sure how to add the form to that. I am not even entirely sure that what I have done so far is right. 

Right now I was attempting to be able to return a PageReference so that the user would be sent to the newly created page and proceed from there, but with this I'm not sure how to attach any JavaScript either. Is there a better way to go about doing this?

 

 

Apex code:

public class pgRefnewWindow {
   
   String s;
   public String Str {get;set;}
   
   public String getU() {
       pStr();
       return s;
   }
    
    public pageReference pStr() {
        s = Str;
        return null;
    }
}

 

 

 

Visualforce Page:

<apex:page controller="pgRefnewWindow" sidebar="false">
    <apex:form >
        <apex:inputText size="36" value="{!Str}"/>
        <apex:commandButton onClick="alert('{!U}');" value="Alert"/>
        <apex:commandButton action="{!pStr}" value="Set String"/>
    </apex:form>
</apex:page>

 

After inputing some text in the form, and click the "Alert", the page always displays null. i.e. It's the previous value of the "inputText".

 

It's ok to display the input only if click "Set String" and then click "Alert".

 

Even, adding the pageReference function in the getter. It doesn't work still... so strange...

 

   public String getU() {
       pStr();
       return s;
   }

 

Just want to know the sequence of the codes between Apex class and Visualforce.

 

And, is it a way to display the inputText right away a click after input ?

 

 

There's format in the String.method, however it's useless.

 

So that if want to add leading zero to a String in Apex controller, it must use a loop to add the leading zeros.

 

=== apex code ===

public class numberFormat {

Integer i = 1234;
String[] fmt1 = new String[]{'0, Number, $000000.00'};
String[] fmt2 = new String[]{'0', 'Number', '$000000.00'};
String[] fmt3 = new String[]{};

public String getNum1() {
return String.format(i.format(),fmt1);
}

public String getNum2() {
return String.format(i.format(),fmt2);
}

public String getNum3() {
return String.format(i.format(),fmt3);
}

public Integer getNum4() {
return i;
}

public Integer getNum5() {
return i;
}
}

 

=== Visualforce Page ===

<apex:page controller="numberFormat">
<apex:outputText value="{!num1}"/><br/>
<apex:outputText value="{!num2}"/><br/>
<apex:outputText value="{!num3}"/><br/>
<apex:outputText value="{!num4}"/><br/>
<apex:outputText value="{0, Number, $000000.00}">
<apex:param value="{!num5}" />
</apex:outputText>
</apex:page>

 

=== The output ===

1,234
1,234
1,234
1234 
$001234.00   

Try this:

 

Parent page (name: page1):

 

<apex:page controller="myTest">

   pageRef: {!pageRef}<br/>
    <apex:include pageName="{!pageRef}"/>
</apex:page>

 

Child page (name: page2):

 

<apex:page showHeader="false" sidebar="false">
    pp: {!$CurrentPage.Parameters.pp}
</apex:page>

 

Controller:

 

public class myTest{
    
    Public PageReference pageRef{get;private set;}
    
    public myTest() {
        pageRef = Page.page2;
        pageRef.getParameters().put('pp','2012');
    }
}

 

The result shows:

 

/apex/page2?pp=2012
pp:

^^^

apex:include doesn't support parameters at all!! Even it's there.......

 

When using Firefox 18, users can't open developer console at all.

 

However, it's ok when using with chrome and IE, and also Firefox 18 safe mode.

 

Even clear all of historial data and cookies, and disable all of plugins and extensions it is unable to open developer console well.

 

Firefox 18 can only open developer console by safe mode.

PHP is easily to integrate with standard object to create, update, query, and delete records.

 

However, just wonder if PHP toolkit supports custom class just like in visualforce page : <apex:page controller="customClass"...

 

I am developing a query page which will do some statistics jobs and I have already developed the task in apex class and visualforce.

 

I know it can be done to rewrite the controller to php code however it will retrieve lots of data to php server that I want to prevent.

 

So, just like to know how to call custom class from PHP toolkit , or it is impossible at the moment.

 

Thanks

Hi,

 

My question to the SF Minds. I am looking to use the auto numbering in SF. My question is, can SF generate an auto number in an Opp? My anwser to that is yes. But can it generate a random number like:

 

Example: Opportunity number 13-5262, then the next Opportunity to be created would look like this 13-4598. 

 

The 4 digits should be a computer generated, non-sequential, completely randomized number so as to not allow how many opportunities we are aware of to be publicized.

 

Any ideas on how I could create this in SF?

 

Thank you SF Minds!

Shawn

  • February 13, 2013
  • Like
  • 0

 

 

Apex code:

public class pgRefnewWindow {
   
   String s;
   public String Str {get;set;}
   
   public String getU() {
       pStr();
       return s;
   }
    
    public pageReference pStr() {
        s = Str;
        return null;
    }
}

 

 

 

Visualforce Page:

<apex:page controller="pgRefnewWindow" sidebar="false">
    <apex:form >
        <apex:inputText size="36" value="{!Str}"/>
        <apex:commandButton onClick="alert('{!U}');" value="Alert"/>
        <apex:commandButton action="{!pStr}" value="Set String"/>
    </apex:form>
</apex:page>

 

After inputing some text in the form, and click the "Alert", the page always displays null. i.e. It's the previous value of the "inputText".

 

It's ok to display the input only if click "Set String" and then click "Alert".

 

Even, adding the pageReference function in the getter. It doesn't work still... so strange...

 

   public String getU() {
       pStr();
       return s;
   }

 

Just want to know the sequence of the codes between Apex class and Visualforce.

 

And, is it a way to display the inputText right away a click after input ?

 

 

Hi, I have a code like below

list<Lead> lstLead = [select Id, Name from Lead];  //line 8

system.dedug('----size---'+lstLead.size()) ;  // line 9

 

In debug log

============

 

Line 8: returns 16120 Rows.

Line 9: debug prints==>    ----size---16074

 

How this is possible? Can anyone help me?

 

Thanks.

 

Hi,

 

I need to be able to print cards that have someone's name and whatnot else on it. I already have a VF page for inputting this information. I would like to be able to dynamically create a VF page from the controller in the original VF page that gathers the correct info, open the newly created VF page so that the user can see it while at the same time bringing up the print dialogue via a javascript call in the header. My current attempt at this from what I have managed to find online looks as follows:

 

public PageReference createCard(String name, String company, String title)
    {
        Component.Apex.Page card = new Component.Apex.Page();
        Component.Apex.Form form = new Component.Apex.Form();
        Component.Apex.OutputLabel visitorName = new Component.Apex.OutputLabel();
        Component.Apex.OutputLabel visitorCompany = new Component.Apex.OutputLabel();
        Component.Apex.OutputLabel visitorTitle = new Component.Apex.OutputLabel();

        visitorName.value='name';
        visitorName.style='text-align:center; font-size:24pt;';
        
        visitorCompany.value='name';
        visitorCompany.style='text-align:center; font-size:24pt;';
        
        visitorTitle.value='name';
        visitorTitle.style='text-align:center; font-size;24pt;';
        
        form.childComponents.add(visitorName);
        form.childComponents.add(visitorCompany);
        form.childComponents.add(visitorTitle);
        
        //Stop point
        
        return null;
    }

 

At this point I am stuck. Since the page object does not have a childComponents field, I'm not sure how to add the form to that. I am not even entirely sure that what I have done so far is right. 

Right now I was attempting to be able to return a PageReference so that the user would be sent to the newly created page and proceed from there, but with this I'm not sure how to attach any JavaScript either. Is there a better way to go about doing this?

There's format in the String.method, however it's useless.

 

So that if want to add leading zero to a String in Apex controller, it must use a loop to add the leading zeros.

 

=== apex code ===

public class numberFormat {

Integer i = 1234;
String[] fmt1 = new String[]{'0, Number, $000000.00'};
String[] fmt2 = new String[]{'0', 'Number', '$000000.00'};
String[] fmt3 = new String[]{};

public String getNum1() {
return String.format(i.format(),fmt1);
}

public String getNum2() {
return String.format(i.format(),fmt2);
}

public String getNum3() {
return String.format(i.format(),fmt3);
}

public Integer getNum4() {
return i;
}

public Integer getNum5() {
return i;
}
}

 

=== Visualforce Page ===

<apex:page controller="numberFormat">
<apex:outputText value="{!num1}"/><br/>
<apex:outputText value="{!num2}"/><br/>
<apex:outputText value="{!num3}"/><br/>
<apex:outputText value="{!num4}"/><br/>
<apex:outputText value="{0, Number, $000000.00}">
<apex:param value="{!num5}" />
</apex:outputText>
</apex:page>

 

=== The output ===

1,234
1,234
1,234
1234 
$001234.00   

Try this:

 

Parent page (name: page1):

 

<apex:page controller="myTest">

   pageRef: {!pageRef}<br/>
    <apex:include pageName="{!pageRef}"/>
</apex:page>

 

Child page (name: page2):

 

<apex:page showHeader="false" sidebar="false">
    pp: {!$CurrentPage.Parameters.pp}
</apex:page>

 

Controller:

 

public class myTest{
    
    Public PageReference pageRef{get;private set;}
    
    public myTest() {
        pageRef = Page.page2;
        pageRef.getParameters().put('pp','2012');
    }
}

 

The result shows:

 

/apex/page2?pp=2012
pp:

^^^

apex:include doesn't support parameters at all!! Even it's there.......

 

When using Firefox 18, users can't open developer console at all.

 

However, it's ok when using with chrome and IE, and also Firefox 18 safe mode.

 

Even clear all of historial data and cookies, and disable all of plugins and extensions it is unable to open developer console well.

 

Firefox 18 can only open developer console by safe mode.