function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Big EarsBig Ears 

Visualforce & Maps - Passing values back to the controller from the page

Dear all,

 

I'm sure there's an obvious workaround for this, but I'm not able to find it.

 

I'd like to create a table/repeat with multiple levels on a visualforce page, as below:

 

  • Product A

Sub-Category 1

Sub-Category 2

Sub-Category 3

  • Product B

Sub-category1...

 

I've achieved this by having a nested <rapex:repeat> tab on the visualforce page.

 

I also need to have an input field against the sub-category level settings, which can then pass values back to the controller (on submit, or similar). However, I'm having difficulties working out how to do so. It seems that I can either create a "flat" list and pass input values back, or have nested lists, but then be unable to do so.

 

Is it possible? Could somebody point me in the right direction? I've tried using maps, but it seems like the values of a map aren't changeable from the visualforce page?

 

With thanks,

Andy

 

 

OzymandiasOzymandias

 

Not sure if I understand your requirement completely, but maybe you could create a wrapper class for the Sub-Category object with a String variable to capture what you put in the input field.

 

e.g.

public class SubCategoryWrapper {
    public SubCategory subCategory {get;set;}
    public String inputText {get;set}
}

 then in the VF page:

<apex:repeat value="{!subCategoryWrapperList}" var="subCategoryWrapper">
   //...markup to display sub-category info...
   <apex:inputField value="{!subCategoryWrapper.inputText}"/>
</apex:repeat>

 

 

Big EarsBig Ears

Ozymandias,

 

Thanks for your response. Sorry for not being clearer. I was trying to access the values within a map within a wrapper class, and then alter those values from the Visualforce page.

 

However, I found a workaround silimar to the one you suggested that removed the need for maps at this time. I also found that there is a way of using maps in Visualforce, as long you're using SObjects to pass the information back and forth between the client and the controller

 

With thanks,

Andy