Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to bind to an object inside HashMap.  RSS feed

Rahul Santha
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a text box in a JSP.
Value of the textbox is present in a DO.
DO is present inside a HashMap.

How do I write the expression in the textbox {#.. blah blah..} to point to the value and display it? Below is my code:

public class PageNameDO {

private String whereAmI = "";

public PageNameDO(String val){
whereAmI = val;
//getters and setters

BackingBean with HashMap inside it:
public class HashBind extends PageCodeBase {

private HashMap<String, PageNameDO> hash1 = null;

public HashBind(){
hash1 = new HashMap<String, PageNameDO>();
hash1.put("A", new PageNameDO("Apple"));

//getters and setters for hashmap

JSP Page:
<h:inputText styleClass="inputText"

How to display the value inside the text box?

Tim Holloway
Posts: 18709
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm going to simplify that request a little to make it clearer, but you should be able to build it up from there.

Let's say you want to display/modify the element in Map myMap in your backing bean that's stored under the key "fruit".

First, you define the property "myMap" with its setter and getter methods. Actually probably just a getter since you probably don't want to replace the whole map.

Now in the input control, you code the value attribute using Java EL:


That's all there is to it.

The unified Expression Language is fairly well documented in the Sun JEE reference documents. A lot of J(2)EE systems use an open-source EL interpreter: the jakarta commons EL project (, which is based on the Jakarta BeanUtils. The BeanUtils are used to resolve property references, so their documentation can be especially helpful.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!