• James@KronosLab
  • NEWBIE
  • 0 Points
  • Member since 2007

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 11
    Replies
We're starting a pilot project with multiple developers.  What, if anything, do people do to handle the issues of source control and schema versioning in an Apex/Force.com universe?  Are we back to the "no one touch file X, I'm working on it" days?

James Turner
Senior Software Engineer, Kronos Labs
I'd like to call an action when a select is changed (using onchange).  However, a plain old submit doesn't call any action.  Looking at what a commandbutton generates, it's pretty hairy and specific, and I can't see a way to emulate it in user-written Javascript.  Any help here?

James
I'm writing an application where I return a complex calculation as part of a getter on a page.  For efficiency, I'd like to cache the results in a group of objects, and only recompute the value if the underlying data becomes 'dirty'

Unfortunately, it seems that there is a DML limit of 0 on getters, because if I try to create any objects at all, I get a "Too many DML Statements: 1" error.

You might want to remove this restriction, as cached computations are a highly useful way to reduce resource requirements.

James
I'd really like to populate parts of a javascript section on my page by iterating over a collection.  However, if I put the <apex:repeat> tag inside of a <script> tag, it is not evaluated.  Thus:

<apex:page controller="RepeatTestController">
{!testStrings}

<apex:repeat var="tstring" value="{!testStrings}"><br/>
var {!tstring};
</apex:repeat>

</apex:page>

Yeilds:
[A, B, C, D, E]<br/>
var A;<br/>
var B;<br/>
var C;<br/>
var D;<br/>
var E;

But:
<apex:page controller="RepeatTestController">
{!testStrings}
<script language="javascript">
<apex:repeat var="tstring" value="{!testStrings}"><br/>
var {!tstring};
</apex:repeat>
</script>
</apex:page>

Yields:
[A, B, C, D, E]
<script language="javascript">
<apex:repeat var="tstring" value="[A, B, C, D, E]"><br/>
var ;
</apex:repeat>

This is a major pain in the butt if you want to populate javascript data on the server side.

James
</script>

I'm developing an application where I would like to be able to relate events to a custom object and use the calendar UI to view them.
 
In other words, let's say I have a Vehicle customer object.  I create an event for each time the vehicle is on the road.  Now I'd like to be able to view all the trips for any one vehicle on a calendar.
 
I can't do it with the standard "Home" calendar because you can't filter the calendar views on a related field.  You can filter the list view, but not the calendar view.
 
I thought an alternative might be to automatically create a public calendar for each vehicle using a trigger, and then put the events for each vehicle on it's own calendar, but I don't think you can create public calendars via Apex, nor can I find how you add events to public calendars programatically.
 
Any ideas?
 
James
Create a page called testpage1 with the follow:
<apex:page controller="testController">
<!-- Begin Default Content REMOVE THIS -->
<h1>Congratulations</h1>
This is your new Apex Page: testpage1
<!-- End Default Content REMOVE THIS -->
<apex:form>
<apex:selectoneradio value="{!testVal}" layout="pageDirection" required="false">
<apex:selectitem itemvalue="test1" itemLabel="test Val 1"/>
</apex:selectoneradio>
<apex:commandbutton action="{!nextPage}" value="Next Page"/>
</apex:form>
</apex:page
 
Define testController as:
public class testController {
public PageReference nextPage() {
return Page.testpage2;
}

String testVal;
public String getTestVal() {
return this.testVal;
}
public void setTestVal(String testVal) {
this.testVal = testVal;
}
}
 
You can't get to the second page unless you click on the radio button, in spite of the required="false". If you change it from a selectOneRadio to an inputText, you can get to the second page without a value.
 
James
Hey all,
   I'm still trying to find out how I can do form validation in an action.  In Triggers, you do it with an addError on the field that caused the problem, but in an Action, I can't find a similar mechanism.  Can someone lend me a hand here?
 
James
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

Ok, so I'm trying to design a wizard, and I want both back and forward button functionality.  Let's say there's a text field that's required.  If I use required='true', and I have commandButtons for Next and Previous, Next works just fine (won't go to next page unless the field is filled out.)  However, the same validation is run for the Previous button, which I can't find a way to disable.  If I set required='false', I suppose I could do the validation in the controller, but I can't find any documentation on how to add error messages to the page in a controller method (nor how to return to the submitting page.)

Any suggestions how to handle this?

James
If I create a new Controller (using either Eclipse or the Visualforce UI), everything works fine... until I try to save the class using Eclipse after adding a Page.whatever reference.  At that point, I start getting:

Compilation error: Page does not exist: WizardPage1

I can work around this by using the new PageReference('/apex/WizardPage1') version, but it would be nice if I could use the "preferred" method in Eclipse.

James


We're starting a pilot project with multiple developers.  What, if anything, do people do to handle the issues of source control and schema versioning in an Apex/Force.com universe?  Are we back to the "no one touch file X, I'm working on it" days?

James Turner
Senior Software Engineer, Kronos Labs
I'd like to call an action when a select is changed (using onchange).  However, a plain old submit doesn't call any action.  Looking at what a commandbutton generates, it's pretty hairy and specific, and I can't see a way to emulate it in user-written Javascript.  Any help here?

James
I'm writing an application where I return a complex calculation as part of a getter on a page.  For efficiency, I'd like to cache the results in a group of objects, and only recompute the value if the underlying data becomes 'dirty'

Unfortunately, it seems that there is a DML limit of 0 on getters, because if I try to create any objects at all, I get a "Too many DML Statements: 1" error.

You might want to remove this restriction, as cached computations are a highly useful way to reduce resource requirements.

James
I'd really like to populate parts of a javascript section on my page by iterating over a collection.  However, if I put the <apex:repeat> tag inside of a <script> tag, it is not evaluated.  Thus:

<apex:page controller="RepeatTestController">
{!testStrings}

<apex:repeat var="tstring" value="{!testStrings}"><br/>
var {!tstring};
</apex:repeat>

</apex:page>

Yeilds:
[A, B, C, D, E]<br/>
var A;<br/>
var B;<br/>
var C;<br/>
var D;<br/>
var E;

But:
<apex:page controller="RepeatTestController">
{!testStrings}
<script language="javascript">
<apex:repeat var="tstring" value="{!testStrings}"><br/>
var {!tstring};
</apex:repeat>
</script>
</apex:page>

Yields:
[A, B, C, D, E]
<script language="javascript">
<apex:repeat var="tstring" value="[A, B, C, D, E]"><br/>
var ;
</apex:repeat>

This is a major pain in the butt if you want to populate javascript data on the server side.

James
</script>

Create a page called testpage1 with the follow:
<apex:page controller="testController">
<!-- Begin Default Content REMOVE THIS -->
<h1>Congratulations</h1>
This is your new Apex Page: testpage1
<!-- End Default Content REMOVE THIS -->
<apex:form>
<apex:selectoneradio value="{!testVal}" layout="pageDirection" required="false">
<apex:selectitem itemvalue="test1" itemLabel="test Val 1"/>
</apex:selectoneradio>
<apex:commandbutton action="{!nextPage}" value="Next Page"/>
</apex:form>
</apex:page
 
Define testController as:
public class testController {
public PageReference nextPage() {
return Page.testpage2;
}

String testVal;
public String getTestVal() {
return this.testVal;
}
public void setTestVal(String testVal) {
this.testVal = testVal;
}
}
 
You can't get to the second page unless you click on the radio button, in spite of the required="false". If you change it from a selectOneRadio to an inputText, you can get to the second page without a value.
 
James
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