开发者

JSF and ajax: listener of dynamically added component never tirggered

I have got a problem with my JSF application. On a page there's a form where the user can dynamically add components to that very same form. When I use the ajax listener to add the component, it is updated in the view and also in the model. But when I try to remove the dynamiccaly added component by pressing an h:actionLink its ajax listener is never triggered.

This is my code:

<h:form rendered="#{schrijvenController.verslagenController.documentSelected}">
                <p>
                    <开发者_JAVA技巧span class="noLabel">
                        #{bundle.JongereJongere}:
                    </span>

                    <h:selectOneMenu id="jongereSelect" valueChangeListener="#{schrijvenController.selecteerJongere}" immediate="true"
                                     value="#{schrijvenController.currentJongere.jongereID}"
                                     title="--#{bundle.JongereSelect}--">
                        <f:selectItems value="#{jongereController.jongerenAsSelectItems}"/>
                    </h:selectOneMenu>
                </p>
                <h:panelGroup id="personen">
                    <ui:repeat value="#{schrijvenController.verslagenController.persoonItems}" var="persoon">                            
                        <div class="div_add_persoon">
                            <div class="div_add_persoon_left">
                                <span class="noLabel"> #{persoon.aanwezigheid}:</span>

                                <h:inputText value="#{persoon.searchTerm}"
                                             onkeypress="if (event.keyCode == 13) { onchange(); return false; }">
                                    <f:ajax event="keypress" render="persoonLijst" listener="#{persoon.getPersonenWhereNameLikeSelectItems}" />
                                </h:inputText> &nbsp;
                                <h:selectOneMenu id="persoonLijst" styleClass="fixedWitdhDropDown"
                                                 value="#{persoon.currentPersoon.persoon_id}"
                                                 title="--#{bundle.PersoonSelect}--">
                                    <f:selectItems value="#{persoon.personenWhereNameLikeSelectItems}"/>
                                    <f:ajax event="change" render="@form" listener="#{persoon.add}" />
                                </h:selectOneMenu>
                            </div>
                            <h:panelGroup layout="block" styleClass="div_add_persoon_right">
                                <ui:repeat value="#{persoon.personen}" var="persoonPersoon">
                                    <h:panelGroup layout="block" styleClass="div_schrijvenPersoon">
                                    <h:outputText value=" #{persoonPersoon.naam} #{persoonPersoon.voornaam} " />
                                    <h:commandLink value="X" id="linkske">
                                        <f:ajax event="click" render="@form" listener="#{persoon.delete}" />
                                    </h:commandLink>
                                    </h:panelGroup>
                                </ui:repeat>
                            </h:panelGroup>
                        </div> 
                    </ui:repeat>
                    <div class="clear" />

This is a Prt Sc of my view: http://i206.photobucket.com/albums/bb69/bartloterman/pscreen.jpg?t=1302028364

If one clicks on an element from the list, it's added to the right inside a div together with a commandLink with the text "x". But when I click the "x" link nothing happens (no function is being executed). It is as if the view can't find the component. I'm using Datamodels.

I've been looking all day for a solution on the web but I couldn't find one. Any help would be greatly appreciated.


I managed to solve the problem by using the following code in my view

<h:commandLink value="X">
      <f:ajax render="@form" execute="@form" listener="#{persoon.delete}" />
</h:commandLink>

Seems I needed render="@form" and execute="@form"

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜