+ Start a Discussion
JeffTrierJeffTrier 

Illegal view ID from String on actionSupport call

Hi guys and gals,

 

I am trying to wrap my head around actionSupport calls within VisualForce, and I keep getting this error:

java.lang.IllegalArgumentException: Illegal view ID

 

I scoured the web, various SFDC entries, and I still can't figure out why this error is happening. Any help would be greatly appreciated.

 

Thanks!

-Jeff

 

 

VisualForce Page:

 

<apex:page StandardController="Case" extensions="VistaCaseExtension">
    <apex:form>
        
        
        <apex:outputPanel id="counter">
            <apex:outputText value="Click Me!" />
            <apex:actionSupport event="onclick"  action="{!myTest}" rerender="counter2" status="refreshstatus" /> 
        </apex:outputPanel>  
        
        <apex:actionStatus id="refreshstatus" startstyle="color:green;" startText="Refreshing...."></apex:actionStatus>
          
        <apex:outputPanel id="counter2">
            <p>
            <apex:outputText value="I want to change!" />
            </p>
        </apex:outputPanel> 
              
    </apex:form>
    
</apex:page>

 

Apex Class

public class VistaCaseExtension {

    // Create extension hook
    private ApexPages.StandardController controller;
    
    String testRet = 'clicked... now what?';
    
    // Constructor
    public VistaCaseExtension(ApexPages.StandardController std){
        controller = std;
    }
    
    public void AccountPopulated() {
        Case cont=(Case) controller.getRecord();
        cont.Account=[select AccountNumber, Site, ShippingStreet from Account where id=:cont.AccountId];
    }    
    
    public String myTest(){
        return testRet;
    }  
    
    
}

 


Best Answer chosen by Admin (Salesforce Developers) 
S91084S91084

Change you code as follows:

 

<apex:page StandardController="Case" extensions="VistaCaseExtension">
    <apex:form>
        
        
        <apex:outputPanel id="counter">
            <apex:outputText value="Click Me!" />
            <apex:actionSupport event="onclick"  action="{!myTest}" rerender="counter2" status="refreshstatus" /> 
        </apex:outputPanel>  
        
        <apex:actionStatus id="refreshstatus" startstyle="color:green;" startText="Refreshing...."></apex:actionStatus>
          
        <apex:outputPanel id="counter2">
            <p>
            <apex:outputText value="{!testRet}" />
            </p>
        </apex:outputPanel> 
              
    </apex:form>
    
</apex:page>


CONTROLLER:

public class VistaCaseExtension {

    // Create extension hook
    private ApexPages.StandardController controller;
    
    public String testRet {get;set;}
    
    // Constructor
    public VistaCaseExtension(ApexPages.StandardController std){
        controller = std;
        testRet = 'I want to change!';
    }
    
    public void AccountPopulated() {
        Case cont=(Case) controller.getRecord();
        cont.Account=[select AccountNumber, Site, ShippingStreet from Account where id=:cont.AccountId];
    }    
    
    public void myTest(){
        testRet='clicked... now what?';
    }  
    
    
}

 

All Answers

vriavmvriavm

Change your code to

    public void myTest(){
  system.debug('Test');
//return testRet; }
or
public PageReference myTest()
{
return null;
}
S91084S91084

Change you code as follows:

 

<apex:page StandardController="Case" extensions="VistaCaseExtension">
    <apex:form>
        
        
        <apex:outputPanel id="counter">
            <apex:outputText value="Click Me!" />
            <apex:actionSupport event="onclick"  action="{!myTest}" rerender="counter2" status="refreshstatus" /> 
        </apex:outputPanel>  
        
        <apex:actionStatus id="refreshstatus" startstyle="color:green;" startText="Refreshing...."></apex:actionStatus>
          
        <apex:outputPanel id="counter2">
            <p>
            <apex:outputText value="{!testRet}" />
            </p>
        </apex:outputPanel> 
              
    </apex:form>
    
</apex:page>


CONTROLLER:

public class VistaCaseExtension {

    // Create extension hook
    private ApexPages.StandardController controller;
    
    public String testRet {get;set;}
    
    // Constructor
    public VistaCaseExtension(ApexPages.StandardController std){
        controller = std;
        testRet = 'I want to change!';
    }
    
    public void AccountPopulated() {
        Case cont=(Case) controller.getRecord();
        cont.Account=[select AccountNumber, Site, ShippingStreet from Account where id=:cont.AccountId];
    }    
    
    public void myTest(){
        testRet='clicked... now what?';
    }  
    
    
}

 

This was selected as the best answer
JeffTrierJeffTrier

Nice! Thanks guys. :)

 

S91084, this did the trick!

 

 

I was wondering, what was happening for the error to occur?

 

Thanks again,

-Jeff

vriavmvriavm

Hi,

 

      For a action method the return type can be void or it can return a PageReference not other data types like String.

 

JeffTrierJeffTrier

Thanks a lot! That helps me grasp this better. :)

 

-Jeff