This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

setting up hashmap key in t:SelectBooleanCheckbox in a dataTable

 
vishnu bola
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

iam new to JSF and have a problem with my t:SelectBooleanCheckbox tag.

In my dataTable there is a column
<t:column>
<t:selectBooleanCheckbox id="checkbox4" value="#{manageuserscontroller.selectedUserIds[user.id-cols.accountID]}" />
</t:column>

the key is a string with a combination of userID and accountID with hyphen(-) in the middle. eg:"123-456" Iam not sure how to dynamically populate the key in my dataTable column. Please advise.

I already posted this query in sun forums http://forums.sun.com/thread.jspa?threadID=5415508 but didn't get a response.So iam reposting the query here. Please advise.
 
Mallika gowd
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
post your code and mention details clearly..please
 
vishnu bola
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi mallika,

Iam happy to see some response. Ok let me copy my entire code below. I have dataTable :
<h:form id="groupuserlist">
<t:dataTable id="groupuserlist"
var="user"
value="#{manageuserscontroller.userList}"
binding="#{manageuserscontroller.userTable}"
styleClass=" marVertSml"
cellspacing="0"
preserveDataModel="false"
headerClass="topRow"
summary="This table displays list of users for an accessgroup">
<t:column>

<f:facet name="header"><hutputText value="User ID" /></f:facet>

<tutputText value="#{user.ID}" />
</t:column>
<t:column>

<f:facet name="header"><t:commandLink value="Title" /></f:facet>

<tutputText value="#{user.title}" />

</t:column>
<t:columns var="cols" value="#{manageuserscontroller.selectedAGList}">
<f:facet name="header"><hutputText value="#{cols.name}" /></f:facet>



<t:selectBooleanCheckbox id="checkbox4" value="#{manageuserscontroller.selectedUserIds[user.ID-cols.accountID]}" />

</t:columns>

In my backing bean ManageUsersController I have hashmap
private Map<String, Boolean> selectedUserIds = new HashMap<String, Boolean>();

This hashmap get populated from the database and the data in it is something like
("123-456",true) where 123 is the userID and 456-accountID.

Now this key acts as checkbox value in my dataTable. Now my problem is iam not able to construct the key inside EL in this format. Kindly need help.





 
Mallika gowd
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

you have selected items in backing bean so concatenate two of them pass it as a string.

If you still not understand this logic..please paste your backing bean code so i can suggest.
 
vishnu bola
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mallika i am not really clear on what you mean by concatenation. Here is my backing bean code.

I am deliberately setting up keys for all the selected checkboxes in that format ("123-456")because i want to extract the userid later for some other processing. I didn't find any other way to to it. Please advise.


 
Mallika gowd
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am not able to understand by looking at the below code.

I will look in to it if you can please post entire code otherwise it is difficult for me to understand piece of codes which are syntactically not correct...
 
salvin francis
Bartender
Posts: 1274
10
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why dont you guys use Code tags ??

Please do so, its makes your post easier to read, It is possible to edit post and add code tags too.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic