• AFawcett (CODA)
  • NEWBIE
  • 0 Points
  • Member since 2007

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 12
    Replies

If you are using the JavaScript Array object in script within your page be sure to check that your correctly iterating over the items within it. If your using for(key in myarray) as apposed to for(var i=0; i<myarray.length;i++) your code will find it is all of sudden finding some some new items in the array! ;-) This article explains the situation and solution pretty well, it's basically down to the fact that the afore mentioned approach is bad practice over the use of Arrays, http://andrewdupont.net/2006/05/18/javascript-associative-arrays-considered-harmful/.

Because we don't always want to use <apex:detail> and yet still want our pages to respond to end user customisations of our objects. I’ve been looking at the <apex:repeat> tag to see what I can achieve as regards dynamically adding controls to a page. I’ve had partial success *, though I am binding to fields on Apex Classes again and not SObject fields ** so no <apex:inputField> benefits… L

 

* Can we nest <apex:repeat>’s as the drop down doesn’t appear to pick up the list items?  L

 

** Would be could to have indirect bindings e.g. <apex:inputField … value=”{!{!field.binding}}”> if you see what I mean?

<apex:page controller="dynamiccontroller">

<table>

<apex:repeat value="{!fields}" var="field" rows="50">

<tr>

<td><apex:outputLabel value="{!field.label}"/></td>

<td>

<apex:inputText rendered="{!field.showText}" value="{!field.text}"/>

<apex:inputCheckbox rendered="{!field.showCheckbox}" value="{!field.boolean}"/>

<apex:selectOneListbox rendered="{!field.showValues}" value="{!field.text}" size="1">

<apex:repeat value="{!field.values}" var="fieldvalue" rows="50">

<apex:selectItem itemValue="{!fieldvalue.value}" itemLabel="{!fieldvalue.label}"/>

</apex:repeat>

</apex:selectOneListbox>

</td>

</tr>

</apex:repeat>

</table>

</apex:page>

 

public class DynamicController

{

        DynamicFieldInfo[] fields;

 

        public DynamicFieldInfo[] getFields()

        {

                if(fields==null)

                {

                        fields = new DynamicFieldInfo[3];

 

                        // Edit

                        fields[0] = new DynamicFieldInfo();

                        fields[0].setLabel('Field A');

                        fields[0].setShowText(true);

                        fields[0].setText('Text');

 

                        // Checkbox

                        fields[1] = new DynamicFieldInfo();

                        fields[1].setLabel('Field B');

                        fields[1].setShowCheckbox(true);

                        fields[1].setBoolean(true);

 

                        // Dropdown

                        fields[2] = new DynamicFieldInfo();

                        fields[2].setLabel('Field C');

                        fields[2].setShowValues(true);

                        List<DynamicFieldInfoValue> values = new List<DynamicFieldInfoValue>();

                        DynamicFieldInfoValue red = new DynamicFieldInfoValue();

                        red.setValue('red');

                        red.setLabel('Red');

                        values.add(red);

                        DynamicFieldInfoValue yellow = new DynamicFieldInfoValue();

                        yellow.setValue('yellow');

                        yellow.setLabel('Yellow');

                        values.add(yellow);

                        fields[2].setValues(values);

                }                

                return fields;

        }

}

I've written an action handler method, that modifies my view state (member variable in my controller) and I would like to redisplay the screen to show the changes. Why doesn't this show "Hello World" when a click the button? Am I expecting something outside the design, I've studied the wizard sample and this works due to the fact it seems to be changing pages in the event handler. Thanks for any help.

<apex:page controller="HelloWorldController">

<apex:form>

<apex:pageBlock title="Hello {!$User.FirstName}!">

<apex:inputTextarea></apex:inputTextarea> value="{!message}"/> <p/>

<apex:commandButton action="{!showmessage}" value="Show Message"/>

</apex:pageBlock>

</apex:form>

</apex:page>

 

public class HelloWorldController

{

String message;

public String getMessage()

{

return message;

}

public PageReference showMessage()

{

message = 'Hello World';

return null;

// Also tried this...no joy either

// return System.currentPageReference();

}

}

I have been doing some research into language translation support. So far I carn't seem to find any reference as to how text used within Apex code can be translated? I guess what i am looking for is something like a Java resource bundle? Anybody got any ideas/thoughts on this?
Is Custom Settings 10MB counted as part of the Org Size Limit or is it added on top of the Org Size Limit? The documentation does not state anything regarding it. Thanks
Message Edited by NinoJose on 02-05-2010 01:41 AM
OK guys, which one of you is going to be the first one to create a Salesforce-Google Wave integration App?

Hi all,

Does anyone know a way to cut down the size of the viewstate that gets posted to and from the server?  We are finding very noticeable performance hits when we do AJAX postbacks (or any kind of postback really).  We have done some investigation and have noticed the viewstate is very large for what we are actually rendering to the browser.  For example:

<apex:page>

           <apex:form>

            </apex:form>

</apex:page>

ViewState size = 1772 bytes

<apex:page standardController="Case">

            <apex:form>

                  <table>

                        <tr><th>Head</th></tr>

                        <tr><td>Content</td></tr>

                  </table>

                  <c:TestComponent />

            </apex:form>

            <apex:outputField value="{!Case.Contact.Name}" />

            <apex:outputPanel />

            <apex:outputText value="Test" />

</apex:page>

<apex:component>

      <table>

            <tr><td>Content In Component</td></tr>

      </table>

</apex:component>

ViewState size = 3756 bytes

As you can see these are simple examples that we have slowly built out to monitor the increase in viewstate.  Naturally as our pages get more complex the viewstate gets excessively large, slowing down the round trip to the SF servers.

Therefore, the questions I have are:

Can we configure the viewstate for each component like ASP.Net allows (or for the entire page)?


Cheers

I was wondering how I can use a custom controller with a class variable, totalAmount, defined as a Double data type and have it displayed as a Currency field in a Visualforce Page? I know if I use a standard controller and use component that Visualforce will automatically render it as a currency field. But how do I accomplish that with a custom controller and a class field defined as a "Double" data type?

To elaborate, the scenario is to display the total amount of multiple line items. The visualforce page allows users to enter multiple lines items with varying amounts and at the bottom there is the "Total" amount. The VF/Apex code is properly aggregate the amount, but it is stored as a Double data type field in the Apex Code controller class - and therefore displayed in the page as a double.


Thanks.

Message Edited by Drew1815 on 04-14-2008 11:33 AM
Next question,

I'd like to use a rerender to allow me to add rows to a table I'm building on a page.  This is the standard type of "you get one line of blank fields, and after you fill it out, you click 'new X' to get a new row to fill in"

I have the table backed by a list, and I can get it to render the row properly.  However, I can't figure out how to call an action on the controller to add the row before I do the rerender.  My first guess was to try:

<apex:commandlink action="addShift" reRender="shiftable" >Add Shift</apex:commandlink>

(where shifttable is an output panel wrapped around the datatable, and addShift is a controller action that adds a new object to the list of objects that the table iterates on)  But what happens, and what I see in Firebug, is that it just does a normal rerender on the datatable without calling the action.  Any hints on how I should do this?

James

I've written an action handler method, that modifies my view state (member variable in my controller) and I would like to redisplay the screen to show the changes. Why doesn't this show "Hello World" when a click the button? Am I expecting something outside the design, I've studied the wizard sample and this works due to the fact it seems to be changing pages in the event handler. Thanks for any help.

<apex:page controller="HelloWorldController">

<apex:form>

<apex:pageBlock title="Hello {!$User.FirstName}!">

<apex:inputTextarea></apex:inputTextarea> value="{!message}"/> <p/>

<apex:commandButton action="{!showmessage}" value="Show Message"/>

</apex:pageBlock>

</apex:form>

</apex:page>

 

public class HelloWorldController

{

String message;

public String getMessage()

{

return message;

}

public PageReference showMessage()

{

message = 'Hello World';

return null;

// Also tried this...no joy either

// return System.currentPageReference();

}

}