English 中文(简体)
发射事件的jsf部件指数
原标题:index of jsf component that fired event
  • 时间:2011-11-14 21:54:08
  •  标签:
  • jsf

这个问题必须是一个大难问题,但我似乎无法找到正确的关键词来讨论:我有一个行动倾听者,可以从一个数据表中同一分界线所产生的多个核对箱中的任何一个收听一次事件。 我怎么能从发表这次活动的听众那里听说?

In particular, I need the index of the component so I can map it to an ordered list in the model. I know I can get the UIComponent object, and from there I can get the client ID of the component. And knowing that the client ID has the component s index embedded in it, yes I could do the sleazy thing, and parse the index from the client ID. But I know that would be a horrible, fragile and unmaintainable hack.

What s the right way to do this?

最佳回答

利用数据表<代码>var属性,你应当能够这样做。

<h:dataTable ...  var="currentRow">
  ....
  <h:selectBooleanCheckbox ... actionListener="#{blah.doThis}">
      <f:attribute name="curRec" value="#{currentRow}" />
  </h:selectBooleanCheckbox>

bean:

public void doThis(ActionEvent ae)
{
    TreeMap myMap = (TreeMap)ae.getComponent().getAttributes().get("curRec");
    ...
}

Edit: The binding variable of your datatable should have the method getRowIndex();. That should give you the index of the record that caused the event in the table. I m referencing an ICEfaces project, so I apologize if that isn t correct. Let me know, thx.

问题回答

在初步搜查之后,我认为这可以帮助你。

rel=“nofollow” http://illegalargument extraion.blogspot.com/2009/02/jsf-working-with-component-ids.html

您是否尝试使用f:除了检查箱的数值外,还采用习惯参数,这样比使用国际发展法来操纵商业逻辑更加清洁。 ID.





相关问题
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 ...

热门标签