You need to sign in to do that
Don't have an account?

Error Saving VF Page Using a CommandLink Action Calling an Inner Class Method With a Map
I have an inner class that has a method I want to call using a Map. I get the following error when trying to save the VF Page. The CommandLink line of code is causing the error.
Error Error: java.lang.UnsupportedOperationException
Error Error: null
Here is the code:
public with sharing class TestInnerClass
{
public TestOuterClass()
<apex:page controller="TestOuterClass">
<apex:form >
<apex:repeat value="{!mapWAcc}" var="idMap">
<apex:repeat value="{!mapWAcc[idMap]}" var="wAcc">
<apex:inputField value="{!wAcc.a.Name}"/>
<apex:commandLink value="Save" action="{!wAcc.saveAcc}"/>
</apex:repeat>
</apex:repeat>
</apex:form>
</apex:page>
Thanks
Error Error: java.lang.UnsupportedOperationException
Error Error: null
Here is the code:
public with sharing class TestInnerClass
{
class wA
{
public Account a {get;set;}
public wA(Account a){this.a = a;}
public void saveAcc(){upsert a;}
public wA(Account a){this.a = a;}
public void saveAcc(){upsert a;}
}
public Map<String,wA> mapWAcc {get;set;}public TestOuterClass()
{
mapWAcc = new Map<String,wA>();
mapWAcc.put('Test',new wA(new Account(Name='Test')));
mapWAcc.put('Test',new wA(new Account(Name='Test')));
}
}<apex:page controller="TestOuterClass">
<apex:form >
<apex:repeat value="{!mapWAcc}" var="idMap">
<apex:repeat value="{!mapWAcc[idMap]}" var="wAcc">
<apex:inputField value="{!wAcc.a.Name}"/>
<apex:commandLink value="Save" action="{!wAcc.saveAcc}"/>
</apex:repeat>
</apex:repeat>
</apex:form>
</apex:page>
Thanks
public PageReference myActionMethod() { ..}
public with sharing class TestInnerClass
{
class wA
{
public Account a {get;set;}
public wA(Account a)
{
this.a = a;
}
public void saveAcc(){upsert a;}
}
public Map<String,wA> mapWAcc {get;set;}
public wA[] listWAcc {get;set;}
public TestInnerClass()
{
mapWAcc = new Map<String,wA>();
listWAcc = new wA[]{};
mapWAcc.put('Test',new wA(new Account(Name='Test')));
listWAcc.add(mapWAcc.get('Test'));
}
}
<apex:page controller="TestInnerClass">
<apex:form >
<!--<apex:repeat value="{!mapWAcc}" var="idMap">-->
<!--<apex:repeat value="{!mapWAcc[idMap]}" var="wAcc">-->
<apex:repeat value="{!listWAcc}" var="wAcc">
<apex:inputField value="{!wAcc.a.Name}"/>
<apex:commandLink value="Save" action="{!wAcc.saveAcc}"/>
</apex:repeat>
<!--</apex:repeat>-->
</apex:form>
</apex:page>
2. As for commandLinks within collections, I suggest you look at this http://bobbuzzard.blogspot.com/2011/07/passing-parameters-to-apex-method-from.html which describes a way to communicate to the controller which map key is being referenced by the commandLink
I did find another post that addresses my issue of accessing an inner class's method thru a map and that it is a SF bug. In my case I can't get the VF page to save. In her case, she can save the VF page, but generates an error during execution (she was using an earlier VF release). Here is the link: https://developer.salesforce.com/forums?id=906F000000098QNIAY