English 中文(简体)
selectBooleanCheckbox - How do I know which checkbox am I selecting or deselecting?
原标题:

I develop something like a shopping cart. I can select multiple items (by clicking on the checkbox next to that item) and add them to a list. How can I know which checkbox I am selecting. If I do this

<h:selectBooleanCheckbox value="#{document.checked}"/>

it only tell me a state of a checkbox is selected or not, but does not tell me which one. Remember the number of items is unknown until runtime since I load them from a datasource, meaning I dont know how many check box there are.

最佳回答

You should have a managed bean from which you get and set the booleans for the different checkboxes (different fields with getter and setters for each checkbox value).

Update: take a look at this example, because I think that is what you should be doing. Where the example says "Employee", you take "Article" or whatever your cart items are.

http://www.javabeat.net/tips/43-how-to-use-hselectbooleancheckbox-within-hd.html

问题回答

暂无回答




相关问题
JSF a4j:support with h:selectManyCheckbox

I m having trouble with a JSF selectManyCheckbox and A4J support. The purpose is to run some action when a checkbox is selected. This works perfectly in Firefox. Yet, when testing in any IE (ie6 / ie7 ...

Mojarra for JSF Encoding

Can anyone teach me how to use mojarra to encode my JSF files. I downloaded mojarra and expected some kind of jar but what i had downloaded was a folder of files i don t know what to do with

如何拦截要求终止?

在共同基金中,如果用户要求终止,就需要采取一些行动。 我需要某种拦截器,但我不知道如何这样做。 我需要帮助。 增 编

ICEFaces inputFile getting the file content without upload

Is there any way of just getting the content of the browsed file without any upload/file transfer operations? I currently use ICEFaces inputFile component but I do not need the default uploading ...

Weird behaviour of h:commandLink action (MethodExpression)

I have two JSPs where I am displaying some info from database in a h:dataTable. One of them is showing all the info, and one of them user specifically. I have showXML.jsp that shows the "XML" column ...

How to correctly use ResultSet with h:dataTable

The problem is, that after displaying the ResultSet with <h:dataTable>, the connection is left open. If I close it, it closes the ResultSet too. I m thinking about copying the ResultSet data ...

热门标签