0

There is a

Map<String,Map<Double,Double>> priceMatrix

I want to use it in a

<ui:repeat value="#{calcModel.priceMatrix.keySet().toArray()}" var="x">
    <div style="display: inline-block; margin-right: 10px">
        <h:inputText value="#{x}" />
    </div>
    <ui:repeat value="#{calcModel.priceMatrix.get(x).keySet().toArray()}" var="y">
        <div style="display: inline-block; margin-right: 10px">
            <h:inputText value="#{y}" />
        </div>
        <div style="display: inline-block;">
            <h:inputText value="#{calcModel.priceMatrix.get(x).get(y)}" />
        </div>
        <br />
    </ui:repeat>

</ui:repeat>

if i post the formular, i get a UpdateModelException with the Message:

value="#{calcModel.priceMatrix.get(x).get(y)}": Illegal Syntax for Set Operation

This issue is making me terrible since over 6 hours. My first idea was to provide own getter and setter in my bean. This dosn't work because jsf calls the getter before calling the setter.

Is there a solution for my problem?

Would it be better to work with List?

Thank you!

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Moinsn
  • 3
  • 1
  • 6
  • My fault, JSF does not require Setters on Maps. And it is able to handle Maps too.. For a simple Map it is like: `` But with a Map in a Map? – Spielername Feb 23 '16 at 12:07
  • If i remove the inner map theres no problem with the post. – Moinsn Feb 23 '16 at 12:13
  • Sorry, I have no idea, did not tried something like this yet. But I am very interested in a possible solution for this use case :) – Spielername Feb 23 '16 at 12:17

1 Answers1

4
<h:inputText value="#{calcModel.priceMatrix.get(x).get(y)}" />

This is indeed not a writable value expression. This represents a read-only value expression. EL can't figure out how to invoke setters on it as the EL expression represents a chain of method calls not nested properties.

You need to replace it by a writable value expression with help of brace notation [] which represents nested properties.

<h:inputText value="#{calcModel.priceMatrix[x][y]}" />

Your other inputs also don't look good, value="#{x}" is surely also not writable, but you'll by now able to figure out the right syntax: just use #{map[key]} syntax instead of #{key}.

Note that this is not specifically a JSF problem. The root cause your exception as you can find further down in stack trace is a javax.el.PropertyNotWritableException. As its package javax.el says, it's an EL problem, not a JSF one.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • That work better but there are still errors. The post works now. But value Changes on are not working. Old values stay after reload. And changes on push a new entry in the map. Thats crazy. Any solution? Thank you. – Moinsn Feb 23 '16 at 15:37
  • @Moinsn, preferably you open new questions for new problems so you don't overburden one person, and others can benefit from the answers. – DavidS Feb 23 '16 at 19:29