This discussion is archived
7 Replies Latest reply: Dec 19, 2012 2:40 PM by EJP RSS

How to reference a Map<String, List<String>> via ValueExpression

980516 Newbie
Currently Being Moderated
Hey guys,

Basically I need to get referenced a value expression based on a Map<String, List<String>>. I won't get in deeper in why I need that but just that we need this complex data structure here.

Well, I have a <ui:repeat> that iterates over a List then each object builds a <p:inputText that maked reference to this "complex" Map. See bellow:

<ui:repeat var="p" value="#{searchBean.searchParameters}" varStatus="status">
                                   <tr>
                                        <td class="accSH9Wxb">
                                             #{p.label}
                                        </td>
                                        
                                        <td class="acGuuIHUjS">
                                             <div class="ZaccXDmCXX AlcXDmCXX">
                                                  <div>
                                                       <span class="accEEXEvb">
                                                            <p:inputText value="#{searchBean.searchParameterValues[p.sigla]}"/>
                                                       </span>
                                                  </div>
                                             </div>
                                        </td>
                                        
                                        <td class="acGuuIHUjS">
                                             <div class="ZaccXDmCXX AlcXDmCXX">
                                                  <div>
                                                       <span class="accEEXEvb">
                                                            <p:inputText value="#{searchBean.searchParameterValues[p.sigla]}"/>
                                                       </span>
                                                  </div>
                                             </div>
                                        </td>
                                        
                                   </tr>
                              </ui:repeat>

Note that I'm doing a #{searchBean.searchParameterValues[p.sigla]}" so this not getting success yet.

So my question is How can I reference a Map<String, List<String>> using ValueExpression?

Thanks
  • 1. Re: How to reference a Map<String, List<String>> via ValueExpression
    gimbal2 Guru
    Currently Being Moderated
    If your "complex" data structure is correct then you're putting a List into an inputText field right now - that is of course not going to work. So what exactly do you want to achieve? Do you want to display an inputText box per index of the list?
  • 2. Re: How to reference a Map<String, List<String>> via ValueExpression
    980516 Newbie
    Currently Being Moderated
    No, i'm not rendering via outputText.

    Imagine this. You have to keep holdded for after processing an structure that is built with CODE which has 2 values. Then I thought that a Map<String,List<String>> could serve for my purposes.

    Those <p:inputText> are being partial updated after <p:selecteManyMenu> item is selected via <p:ajax> event. Till there, everything is all right. However my only issue is that I'm not able to post those <p:inputText> correctly because their value expression are wrong.

    So I was wondering that what if is possible to make a reference to this "complex" map as I'm saynn...

    Any tips will be wonderful

    Thanks
  • 3. Re: How to reference a Map<String, List<String>> via ValueExpression
    980516 Newbie
    Currently Being Moderated
    Look what I've done now in order to get this work but with not succes.

    I changed my value's map to a classe of ValueContent like this Map<String,ValueContent> and in the view side I did this

    <p:inputText value="#{searchBean.searchParameterValues[p.sigla].valueContent.iniValue}"/>

    My ValueContent is

    class ValueContent implements Serializeble {
    private String iniValue;
              private String endValue;
              
              public ValueContent() {
                   
              }

    // getters and setters...
    }

    And now I getting this error

    javax.el.PropertyNotFoundException: /pages/portal/searcharea.xhtml @108,102 value="#{searchBean.searchParameterValues[p.sigla].valueContent.iniValue}": Property 'valueContent' not found on type br.com.agens.titanium.ui.bean.SearchBean$ValueContent
  • 4. Re: How to reference a Map<String, List<String>> via ValueExpression
    EJP Guru
    Currently Being Moderated
    So the searchParameterValues already are type ValueContent, so you don't need .valueContent in the EL.
  • 5. Re: How to reference a Map<String, List<String>> via ValueExpression
    980516 Newbie
    Currently Being Moderated
    hey, I guess I was making a mistake since it's not possible to reference of an Object like ValueContent without a Converter. So I create one and everything was all right!
  • 6. Re: How to reference a Map<String, List<String>> via ValueExpression
    gimbal2 Guru
    Currently Being Moderated
    GuitarBrasil wrote:
    hey, I guess I was making a mistake since it's not possible to reference of an Object like ValueContent without a Converter. So I create one and everything was all right!
    It is possible to reference them, but it is not possible to dump them in a component that works on a string basis without some kind of conversion.
  • 7. Re: How to reference a Map<String, List<String>> via ValueExpression
    EJP Guru
    Currently Being Moderated
    since it's not possible to reference of an Object like ValueContent without a Converter.
    Yes it is. You only need Converters for elements that are displayed and entered.
    So I create one and everything was all right!
    You didn't need to do that. You just needed to remove .valueContent, as I said. If you're not going to actually+try+ what you are told here, I fail to see the point of posting at all.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points