This week's book giveaway is in the Server-Side JavaScript and NodeJS forum.
We're giving away four copies of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques and have Mario Casciaro & Luciano Mammino on-line!
See this thread for details.
Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

setting up hashmap key in t:SelectBooleanCheckbox in a dataTable

 
Ranch Hand
Posts: 41
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
post your code and mention details clearly..please
 
vishnu bola
Ranch Hand
Posts: 41
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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"><h:outputText value="User ID" /></f:facet>

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

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

<t:outputText value="#{user.title}" />

</t:column>
<t:columns var="cols" value="#{manageuserscontroller.selectedAGList}">
<f:facet name="header"><h:outputText 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 41
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Bartender
Posts: 2880
150
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic