• Gazza
  • NEWBIE
  • 0 Points
  • Member since 2010

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

Hi,

 

The Problem I’m having is that the actionSupport function SearchTemplates from my dependent picklist is only running once when I set the value. When I change the values again it does not run my SearchTemplates method. What is happening is that Salesforce is removing the onchange event from my select list after running the action once. I think this maybe a Salesforce bug. Is there a workaround with out changing my data model?

 

Below is a simple code example of what I am trying to do:

 

Visualforce Page

 

<apex:page controller="TemplateCont" >
<apex:form >
<apex:actionRegion >
<apex:inputField value="{!aTemplate.Category__c}"/>
<apex:inputField value="{!aTemplate.Subcategory__c}">
<apex:actionSupport action="{!SearchTemplates}" event="onchange" rerender="matchingTemplates" status="status"/>
</apex:inputField>
<apex:actionStatus startText=" Please wait..." id="status"/>
</apex:actionRegion>

<apex:pageBlock title="Matching Templates" id="matchingTemplates" >

{!MatchingTemplates.size}

</apex:pageBlock>

</apex:form>
</apex:page>

Controller

 

 

public with sharing class TemplateCont {
public Template__c aTemplate{get; set;}
public List<Template__c> matchingTemplates{get; private set;}
public TemplateCont(){ aTemplate = new Template__c(); matchingTemplates = new List<Template__c>(); } public void SearchTemplates(){ matchingTemplates = [SELECT name, category__c, subcategory__c FROM Template__c where category__c=:aTemplate.Category__c and subCategory__c=:aTemplate.Subcategory__c]; } }

 

 

Would be greatfull for any help.

 

Thanks

 

Peter

  • July 30, 2010
  • Like
  • 0

Hi,

 

The Problem I’m having is that the actionSupport function SearchTemplates from my dependent picklist is only running once when I set the value. When I change the values again it does not run my SearchTemplates method. What is happening is that Salesforce is removing the onchange event from my select list after running the action once. I think this maybe a Salesforce bug. Is there a workaround with out changing my data model?

 

Below is a simple code example of what I am trying to do:

 

Visualforce Page

 

<apex:page controller="TemplateCont" >
<apex:form >
<apex:actionRegion >
<apex:inputField value="{!aTemplate.Category__c}"/>
<apex:inputField value="{!aTemplate.Subcategory__c}">
<apex:actionSupport action="{!SearchTemplates}" event="onchange" rerender="matchingTemplates" status="status"/>
</apex:inputField>
<apex:actionStatus startText=" Please wait..." id="status"/>
</apex:actionRegion>

<apex:pageBlock title="Matching Templates" id="matchingTemplates" >

{!MatchingTemplates.size}

</apex:pageBlock>

</apex:form>
</apex:page>

Controller

 

 

public with sharing class TemplateCont {
public Template__c aTemplate{get; set;}
public List<Template__c> matchingTemplates{get; private set;}
public TemplateCont(){ aTemplate = new Template__c(); matchingTemplates = new List<Template__c>(); } public void SearchTemplates(){ matchingTemplates = [SELECT name, category__c, subcategory__c FROM Template__c where category__c=:aTemplate.Category__c and subCategory__c=:aTemplate.Subcategory__c]; } }

 

 

Would be greatfull for any help.

 

Thanks

 

Peter

  • July 30, 2010
  • Like
  • 0