• eliotstock
  • NEWBIE
  • 25 Points
  • Member since 2009

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

Hi there

 

I have a form with some inputField tags on a page that uses a custom controller. I would expect the setter method for the field to be called on my controller before save() is called, but this doesn't happen.

 

page:

 

 

<apex:page controller="MetricController"> <apex:sectionHeader title="Metric Creation" /> <apex:form > <apex:pageBlock mode="edit"> <apex:pageMessages /> <apex:pageBlockButtons > <apex:commandButton action="{!save}" value="Save"/> <apex:commandButton action="{!cancel}" value="Cancel" immediate="true"/> </apex:pageBlockButtons> <apex:pageBlockSection title="Information" columns="2"> <apex:inputField value="{!metric.Metric_Definition__c}" required="true"/> <apex:inputField value="{!metric.Starting_Value__c}" /> <!-- etc --> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>

 and controller:

 

 

public class MetricController { private Metric__c metric; private Metric_Definition__c metricDefinition; private String debug = ''; public MetricController() { this.metric = new Metric__c(); debug += 'new, empty Metric Definition Id: ' + this.metric.Metric_Definition__c; this.metricDefinition = new Metric_Definition__c(); } public Metric__c getMetric() { return this.metric; } public void setMetric(Metric__c metric) { debug += ', setMetric() called with a metric that has a metric definition with id: ' + metric.Metric_Definition__c; this.metric = metric; } public Metric_Definition__c getMetricDefinition() { return this.metricDefinition; } public void setMetricDefinition(Metric_Definition__c metricDefinition) { this.metricDefinition = metricDefinition; } public PageReference save() { Id defId = this.metric.Metric_Definition__c; debug += ', same Id but within save(): ' + defId; String notes = this.metric.Data_Collection_Notes__c; debug += ', notes: ' + notes; // Poor man's debug System.assert(false, debug); String accountId = ApexPages.currentPage().getParameters().get('AccountId'); this.metric.Organization__c = accountId; insert this.metric; return new PageReference('/' + metric.Id); } }

 

 In my debug I never see the text I add during the call to the setter. Any ideas?

 

 

 

Hi there,

 

I have a Visualforce page with two fields on it using <apex:inputField> tags. One or the other must be populated. If both are populated, that's fine too - my controller will do the right thing.

 

What's the best way to handle this? At the moment I have required="true" on both but it'd be nice to use some javascript to disable one when you click in the other. Is there anything like this out of the box in Visuaforce?

 

Hi there.

 

I can't figure out how to circumvent validation when clicking a cancel button on a Visualforce page that uses a custom controller.

 

The page has this button:

 

 

<apex:commandButton action="{!cancel}" value="Cancel"/>

 

And the cancel method in the controller does this:

 

 

public PageReference cancel() { System.debug('cancel()'); String accountId = ApexPages.currentPage().getParameters().get('AccountId'); return new PageReference(accountId); }

 

 but I never see my debug. Instead I see all the required fields on the page with red boxes ("Error: You must enter a value"). Any help would be appreciated.

 

Thanks.

 

 

Hi there

 

I have two custom objects with a master-detail relationship, CustomProject__c and CustomPayment__c. CustomProject__c is the parent and can have many payments. I have a set of IDs of payments and want to find all the parents of these payments.

 

 

SELECT Id, Name, TotalPayments__c, (SELECT Id, Amount__c FROM CustomPayments__r WHERE Id IN :paymentIds) FROM CustomProject__c

 


 

 

I would expect this to give me just the CustomProject__c parents that have CustomPayment__c children with IDs in the list paymentIds. It doesn't. Instead I get *all* CustomProject__c parents. Can anyone shed any light on this?

 

Thanks,

 

Eliot Stock.

Message Edited by eliotstock on 05-11-2009 06:04 AM

Hi there

 

I have a form with some inputField tags on a page that uses a custom controller. I would expect the setter method for the field to be called on my controller before save() is called, but this doesn't happen.

 

page:

 

 

<apex:page controller="MetricController"> <apex:sectionHeader title="Metric Creation" /> <apex:form > <apex:pageBlock mode="edit"> <apex:pageMessages /> <apex:pageBlockButtons > <apex:commandButton action="{!save}" value="Save"/> <apex:commandButton action="{!cancel}" value="Cancel" immediate="true"/> </apex:pageBlockButtons> <apex:pageBlockSection title="Information" columns="2"> <apex:inputField value="{!metric.Metric_Definition__c}" required="true"/> <apex:inputField value="{!metric.Starting_Value__c}" /> <!-- etc --> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>

 and controller:

 

 

public class MetricController { private Metric__c metric; private Metric_Definition__c metricDefinition; private String debug = ''; public MetricController() { this.metric = new Metric__c(); debug += 'new, empty Metric Definition Id: ' + this.metric.Metric_Definition__c; this.metricDefinition = new Metric_Definition__c(); } public Metric__c getMetric() { return this.metric; } public void setMetric(Metric__c metric) { debug += ', setMetric() called with a metric that has a metric definition with id: ' + metric.Metric_Definition__c; this.metric = metric; } public Metric_Definition__c getMetricDefinition() { return this.metricDefinition; } public void setMetricDefinition(Metric_Definition__c metricDefinition) { this.metricDefinition = metricDefinition; } public PageReference save() { Id defId = this.metric.Metric_Definition__c; debug += ', same Id but within save(): ' + defId; String notes = this.metric.Data_Collection_Notes__c; debug += ', notes: ' + notes; // Poor man's debug System.assert(false, debug); String accountId = ApexPages.currentPage().getParameters().get('AccountId'); this.metric.Organization__c = accountId; insert this.metric; return new PageReference('/' + metric.Id); } }

 

 In my debug I never see the text I add during the call to the setter. Any ideas?

 

 

 

Hi there,

 

I have a Visualforce page with two fields on it using <apex:inputField> tags. One or the other must be populated. If both are populated, that's fine too - my controller will do the right thing.

 

What's the best way to handle this? At the moment I have required="true" on both but it'd be nice to use some javascript to disable one when you click in the other. Is there anything like this out of the box in Visuaforce?

 

Hi there.

 

I can't figure out how to circumvent validation when clicking a cancel button on a Visualforce page that uses a custom controller.

 

The page has this button:

 

 

<apex:commandButton action="{!cancel}" value="Cancel"/>

 

And the cancel method in the controller does this:

 

 

public PageReference cancel() { System.debug('cancel()'); String accountId = ApexPages.currentPage().getParameters().get('AccountId'); return new PageReference(accountId); }

 

 but I never see my debug. Instead I see all the required fields on the page with red boxes ("Error: You must enter a value"). Any help would be appreciated.

 

Thanks.

 

 

Hi there

 

I have two custom objects with a master-detail relationship, CustomProject__c and CustomPayment__c. CustomProject__c is the parent and can have many payments. I have a set of IDs of payments and want to find all the parents of these payments.

 

 

SELECT Id, Name, TotalPayments__c, (SELECT Id, Amount__c FROM CustomPayments__r WHERE Id IN :paymentIds) FROM CustomProject__c

 


 

 

I would expect this to give me just the CustomProject__c parents that have CustomPayment__c children with IDs in the list paymentIds. It doesn't. Instead I get *all* CustomProject__c parents. Can anyone shed any light on this?

 

Thanks,

 

Eliot Stock.

Message Edited by eliotstock on 05-11-2009 06:04 AM
I created a picklist field with three values - One, Two and Three. I set One to be the Default.
 
When I display the picklist field on a visualforce page using inputfield, the drop-down list shows --None-- as the initial item.
 
Am I missing something or shouldn't One be the default?