JSF 2 partial Validation without RichFaces - validation

I have the next jsf form with 2 parts
1) Header Form
2) Datatable Fields
I want add validation to 2 parts, but when i will do post the header form the validation of datatable is not necessary, and when i do update row datatable the validation of the header form is not necessary. My Problem is that when i do post the update row datatable, the jsf wants validate the header form..
My question is..
Using only JSF 2 Implementation without rich faces or another library, how to i do to jsf to validate a partial form? what is the best way to manage subforms?
Thanks,
This is my example Code
<h:form styleClass="horizontal-form" id="form">
<h:messages></h:messages>
<h3>
<h:outputText value="#{msgs.title}"></h:outputText>
</h3>
<table>
<tr>
<td><h:outputLabel for="userName" id="nameLbl">Name</h:outputLabel></td>
<td><h:inputText id="userName" value="#{actionBean.name}"
styleClass="form-control" required="true" /> <h:message
for="userName"></h:message></td>
</tr>
<tr>
<td>Monto:</td>
<td><h:inputText id="userAmount" value="#{actionBean.amount}"
label="Edad" /> <h:message for="userAmount"></h:message></td>
</tr>
</table>
<div>
Datatable
<h:dataTable value="#{actionBean.items}" var="item" id="datatable">
<h:column>
<f:facet name="header">
<h:outputText value="Nombre"></h:outputText>
</f:facet>
<h:outputText value="#{item.data.name}" rendered="#{!item.edit}"></h:outputText>
<h:inputText id="inputName" value="#{item.editData.name}" required="true"
rendered="#{item.edit}"></h:inputText>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Actions"></h:outputText>
</f:facet>
<h:commandButton value="Edit"
action="#{actionBean.edit(item)}" rendered="#{!item.edit}"
immediate="true" styleClass="btn btn-sm btn-primary">
<f:ajax execute="form" render="form" />
</h:commandButton>
<h:commandButton value="Update"
action="#{actionBean.update(item)}" rendered="#{item.edit}"
styleClass="btn btn-sm btn-primary ">
<f:ajax execute="datatable" render="form" />
</h:commandButton>
</h:column>
</h:dataTable>
</div>
<p>
<h:commandButton value="Login" action="#{actionBean.count}"
styleClass="btn btn-sm btn-primary">
<f:ajax execute="form" render="form datatable_form" />
</h:commandButton>
<h:commandButton value="Begin" action="index" immediate="true"
styleClass="btn btn-sm btn-primary" />
</p>
</h:form>

It's probably happening because you are trying to update the whole form instead of just the datatable.
Example:
<h:commandButton value="Edit"
action="#{actionBean.edit(item)}" rendered="#{!item.edit}"
immediate="true" styleClass="btn btn-sm btn-primary">
<f:ajax execute="form" render="form" />
</h:commandButton>
In this case you should try to execute/render just the datable you want do validate, just like this:
<h:commandButton value="Edit"
action="#{actionBean.edit(item)}" rendered="#{!item.edit}"
immediate="true" styleClass="btn btn-sm btn-primary">
<f:ajax execute="datatable" render="datatable" />
</h:commandButton>

Related

f:ajax validation shows only one message at once

I'm working on JSF form with field validation.
<h:form>
<h:panelGrid id="panel" styleClass="data_table_pricing" columns="3">
<h:outputText value="Title"/>
<h:inputText id="title" value="#{pricingForm.title}" validatorMessage="Value is too big.">
<f:validateLength minimum="0" maximum="40" />
<f:ajax event="change" render="#form"/>
</h:inputText>
<h:message id="title_message" for="title" style="color:red"/>
<!-- // -->
<h:outputText value="First name"/>
<h:inputText id="first_name" value="#{pricingForm.firstName}" validatorMessage="Value is too big.">
<f:validateLength minimum="0" maximum="40" />
<f:ajax event="change" render="#form"/>
</h:inputText>
<h:message id="first_name_message" for="first_name" style="color:red"/>
<!-- // -->
<h:outputText value="Last name"/>
<h:inputText id="last_name" value="#{pricingForm.lastName}" validatorMessage="Value is too big.">
<f:validateLength minimum="0" maximum="40" />
<f:ajax event="change" render="#form"/>
</h:inputText>
<h:message id="last_name_message" for="last_name" style="color:red"/>
<!-- // -->
</h:panelGrid>
<h:commandLink value="reset" class="link" type="reset" style="margin: 20px;">
<f:ajax execute="#form" render="#form"/>
</h:commandLink>
<h:commandLink value="Next" class="link" style="margin: 20px;" actionListener="#{pricingForm.calculatorPage()}">
<f:ajax execute="#form" render="#form"/>
</h:commandLink>
</h:form>
When I insert into several input fields big values I see only one error message. Looks like when the form is rendered the old values are not saved. San you help me to solve this?
This,
<f:ajax event="change" render="#form"/>
means the same as: "when the value of the current input is changed, submit and process only the current input and update the whole form".
So, other inputs aren't processed/validated, and the update basically clears out previous messages.
You likely meant to update only the associated message. E.g. in case of your first input:
<f:ajax render="title_message" />
I only omitted event="change" as that's the default already in <h:inputXxx> components.
See also:
Understanding PrimeFaces process/update and JSF f:ajax execute/render attributes

JSF + primefaces spinner ajax invoking other submits

I'm using ajax in spinner to call some action in backing bean.
this is my code:
<b:panel>
<p:dataTable id="orderDataTable" var="order" value="#{orderViewBean.orders}"
widgetVar="ordersDataTable" tableStyle="table-layout: auto;">
<p:column headerText="Created" filterBy="#{order.creationDate}" filterStyle="display: none"
filterMatchMode="contains">
<h:outputText value="#{order.creationDate}"/>
</p:column>
<p:column headerText="Created By" filterBy="#{order.createdBy}" filterStyle="display: none"
filterMatchMode="contains">
<h:outputText value="#{order.createdBy}"/>
</p:column>
</p:dataTable>
<b:panelGrid colSpans="4,4,4">
<b:commandButton action="#{orderViewBean.previousPage}" value="Previous"
look="primary" process="#this:uploadOrderDataPanel" styleClass="pull-left"
disabled="#{!orderViewBean.page.hasPrevious()}" type="submit">
<p:ajax immediate="true" update=":companyOrdersForm"/>
</b:commandButton>
<b:row>
<div class="text-center">
<h:outputLabel value="Page"/>
<p:spinner value="#{orderViewBean.currentPage}" size="3"
min="#{orderViewBean.page.totalPages > 0 ? 1 : 0}"
max="#{orderViewBean.page.totalPages}">
<p:ajax listener="#{orderViewBean.changePageAjax}"
update="#form" process="#this" immediate="true"/>
</p:spinner>
<h:outputLabel value="Of"/>
<h:outputText value="#{orderViewBean.page.totalPages}"/>
</div>
</b:row>
<b:commandButton action="#{orderViewBean.nextPage}" value="Next"
look="primary" process="#this:uploadOrderDataPanel" styleClass="pull-right"
disabled="#{!orderViewBean.page.hasNext()}" type="submit">
<p:ajax immediate="true" update=":companyOrdersForm"/>
</b:commandButton>
</b:panelGrid>
</b:panel>
When I put some number into spinner and hit enter, then changePageAjax is invoked (this is ok) and also orderViewBean.previousPage (this is not ok). Can I avoid invoking other actions?
Add a partialSubmit="true" attribute on the relevant ajax tags.. From the PF documentation:
PartialSubmit reduces network traffic by only adding the partially processed components to the ajax request post. For big pages with many input components, partialSubmit is extremely useful as it leads to more lightweight requests. Compare the Post Data displayed by the logger for the difference.
See also:
http://www.primefaces.org/showcase/ui/ajax/partialSubmit.xhtml

Redirecting with return statement influences the rendering process in next page

I have a problem with the rendering of a datatable.
In my application I have this navigation bar:
<h:form>
<ul class="nav nav-tabs">
<li class="active" role="presentation">
<h:commandLink value="Veranstaltungen" action="#{eventController.redirect('veranstaltung.xhtml')}"/>
</li>
<li role="presentation">
<h:commandLink value="Beacons" action="#{beaconcontroller.redirect('beacon.xhtml')}"/>
</li>
[...]
</ul>
</h:form>
Redirect (beaconcontroller):
public String redirect(String link) {
beacons = database.getAllBeacons();
return "./" + link;
}
The navigation works perfectly, but when I submit the form beaconData in the beacon.xhtml my datatable won't be rendered.
<h:form id="beaconsTable">
<p:dataTable value="#{beaconcontroller.beacons}" var="b"
tableStyleClass="table table-striped"
emptyMessage="Keine Beacons verfügbar"
style="font-size:14px"
rowIndexVar="rowIndex"
rowStyleClass="#{(rowIndex mod 2) eq 0 ? 'first-row' : 'second-row'}"
>
<p:column style="float:left;border:none;">
<f:facet name="header">
<h:commandLink actionListener="#{beaconcontroller.sortBeacons}">
<f:ajax execute="#this" render="beaconsTable"/>
Beacons
</h:commandLink>
</f:facet>
<h:commandLink>
<f:ajax listener="#{beaconcontroller.fillFields(b)}" execute="#this" render=":beaconData beaconsTable :delete"/>
<h:outputText value="#{beaconcontroller.getCompleteString(b)}" style="#{beaconcontroller.currentBeacon == b ? 'color:#337AB7' : 'color:#555555'}"></h:outputText>
</h:commandLink>
</p:column>
</p:dataTable>
</h:form>
</div>
<div class="col-lg-6">
<h:form role="form" id="beaconData" enctype="multipart/form-data">
<div class="form-group">
<label>UUID*</label>
<h:inputText id="id_uuid" binding="#{uuidAttribute}" class="form-control" value="#{beaconcontroller.uuid}" p:placeholder="Unternehmen" required="true" requiredMessage="Bitte UUID angeben" validatorMessage="Bitte nur Zahlen und Buchstaben angeben">
<f:validateRegex pattern="[0-9a-zA-Z]+"/>
</h:inputText>
<h:message styleClass="errMessage" for="id_uuid" style="color: red"/>
</div>
[...]
<h:commandButton type="submit" value="Speichern" actionListener="#{beaconcontroller.saveData}" class="btn btn-primary" disabled="#{beaconcontroller.currentBeacon == null}">
<f:ajax render="beaconData :beaconsTable" execute="#form"/>
</h:commandButton>
</h:form>
</div>
Clicking on an other entry in the datatable, solves the problem. Then the table will be rendered on submit. But why dosen't it work on the first time?
When I now change action="#{beaconcontroller.redirect('beacon.xhtml')}" in the navigation bar to action="beacon.xhtml" it works all correct. I thought these expressions are meaning the same?

AJAX not firing in JSF 2.0

I have a problem that my AJAX requests are not firing in JSF, for unknown reasons.
admin.xhtml Snippet:
<h:form id="adminPanel">
...
<f:subview id="editCustomer#{customer.id}">
<p class="#{adminService.getEditCustomerClass(customer.id)}">
<h:inputText id="email#{customer.id}" value="#{adminService.customerEmail}"/><br/>
<h:inputText id="firstName#{customer.id}" value="#{adminService.customerFirstName}"/>
<h:inputText id="lastName#{customer.id}" value="#{adminService.customerLastName}"/><br/>
<h:commandButton id="saveEdit#{customer.id}" type="button" value="Save">
<f:ajax render="#form" event="click" listener="#{adminService.saveCustomer()}"/>
</h:commandButton>
<h:commandButton id="cancelEdit#{customer.id}" type="button" value="Cancel">
<f:ajax render="#form" event="click" listener="#{adminService.cancelEdit()}"/>
</h:commandButton>
</p>
</f:subview>
...
</h:form>
AdminService.java Snippet:
#Named
#Stateless
#LocalBean
public class AdminService {
public String getEditCustomerClass(int id) {
return id != customerId ? "hidden" : "";
}
public void saveCustomer() {
cancelEdit();
}
public void cancelEdit() {
movieId = -1;
customerId = -1;
orderId = -1;
actorId = -1;
employeeId = -1; //if none of the id's match, p should return 'hidden' class and not be seen.
}
}
Originally I had problems because instead of hiding and showing with CSS, I was using the "rendered=" attribute. However, I heard that partial rendering of views can break AJAX, so I phased it out, hoping that not partially rendering the view (only hiding and showing it) would fix the problem.
However this ajax is still not calling the method I specified in the listener attribute (the entire page is a lot bigger and uses a lot more AJAX, though the rest of it works until these buttons are pressed, then other ajax buttons stop responding.)
If I change the button type to submit, it will actually perform the listener method if I press the button twice, but then the other ajax links don't call their respective listener methods.
How can I get this to work?
Update:
Here is the information from POST request that JSF fires on click:
Request Headers:
Accept:*/*
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Length:2186
Content-type:application/x-www-form-urlencoded;charset=UTF-8
Cookie:JSESSIONID=7342e0de92edc023eecbf706dae3
Faces-Request:partial/ajax
Host:www.minimalcomputers.com:8181
Origin:https://www.minimalcomputers.com:8181
Referer:https://www.minimalcomputers.com:8181/MovieProject/Admin/admin.xhtml
User-Agent:Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31
Form Data:
adminPanel:adminPanel
adminPanel:representativeActionPane:customerPane:customersList:0:editCustomer1:email1:phroph#yahoo.com
adminPanel:representativeActionPane:customerPane:customersList:0:editCustomer1:firstName1:
adminPanel:representativeActionPane:customerPane:customersList:0:editCustomer1:lastName1:
adminPanel:representativeActionPane:customerPane:customersList:1:editCustomer1:email1:phroph#yahoo.com
adminPanel:representativeActionPane:customerPane:customersList:1:editCustomer1:firstName1:
adminPanel:representativeActionPane:customerPane:customersList:1:editCustomer1:lastName1:
adminPanel:representativeActionPane:customerPane:customersList:2:editCustomer1:email1:phroph#yahoo.com
adminPanel:representativeActionPane:customerPane:customersList:2:editCustomer1:firstName1:
adminPanel:representativeActionPane:customerPane:customersList:2:editCustomer1:lastName1:
adminPanel:representativeActionPane:customerPane:customersList:3:editCustomer1:email1:phroph#yahoo.com
adminPanel:representativeActionPane:customerPane:customersList:3:editCustomer1:firstName1:
adminPanel:representativeActionPane:customerPane:customersList:3:editCustomer1:lastName1:
adminPanel:representativeActionPane:customerPane:customersList:4:editCustomer1:email1:phroph#yahoo.com
adminPanel:representativeActionPane:customerPane:customersList:4:editCustomer1:firstName1:
adminPanel:representativeActionPane:customerPane:customersList:4:editCustomer1:lastName1:
javax.faces.ViewState:1088200739038195170:4402027985833798256
javax.faces.source:adminPanel:representativeActionPane:customerPane:customersList:0:editCustomer1:cancelEdit1
javax.faces.partial.event:click
javax.faces.partial.execute:adminPanel:representativeActionPane:customerPane:customersList:0:editCustomer1:cancelEdit1 adminPanel:representativeActionPane:customerPane:customersList:0:editCustomer1:cancelEdit1
javax.faces.partial.render:adminPanel
javax.faces.behavior.event:click
javax.faces.partial.ajax:true
Response Header
Cache-Control:no-cache
Content-Type:text/xml;charset=UTF-8
Date:Thu, 02 May 2013 21:45:05 GMT
Server:GlassFish Server Open Source Edition 3.1.2.2
Transfer-Encoding:chunked
X-Powered-By:Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2.2 Java/Sun Microsystems Inc./1.6)
X-Powered-By:JSF/2.0
Update 2:
When I switch to commandButtons of type "submit" without AJAX, it works as expected (except some of the buttons requires two clicks to activate). So the problem is localized to the f:ajax tags.
Update 3:
The entire base of code for admin.xhtml. IT's a bit unclean because it's in the process of being debugged and trying things to make it work.
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.min.js"/>
<h:outputStylesheet name="header.css" library="css"/>
<link href='http://fonts.googleapis.com/css?family=Noto+Sans' rel='stylesheet' type='text/css'/>
<title>VideoPile - Administration</title>
</h:head>
<h:body>
<div id="body">
<ui:insert name="header" >
<ui:include src="/templates/header.xhtml" />
</ui:insert>
<div id="content">
Admin.
<h:form id="adminPanel">
<!--<h:commandButton id="admin" value="Administrative Actions" rendered="{adminService.hasAdminPrivileges()}">
<f:ajax render="#form" event="click" listener="{adminService.toggleAdminPane()}"/>
</h:commandButton>-->
<h:commandButton id="manager" type="button" value="Manager Actions" rendered="#{adminService.hasManagerPrivileges()}">
<f:ajax render="#form" event="click" listener="#{adminService.toggleManagerPane()}"/>
</h:commandButton>
<h:commandButton id="representative" type="button" value="Representative Actions" rendered="#{adminService.hasRepresentativePrivileges()}">
<f:ajax render="#form" event="click" listener="#{adminService.toggleRepresentativePane()}" />
</h:commandButton>
<br/>
<!--<f:subview id="administrativeActionPane" rendered="{userService.showAdminPane}">
Admin Pane
</f:subview>-->
<f:subview id="managerialActionPane">
<div class="#{adminService.getShowManagerClass()}">
Manager Pane:
<h:commandLink id="editmovies" value="Movies">
<f:ajax render="#form" event="click" listener="#{adminService.toggleMoviePane()}"/>
</h:commandLink>
<h:commandLink id="employes" value="Employees">
<f:ajax render="#form" event="click" listener="#{adminService.toggleEmployeePane()}"/>
</h:commandLink>
<h:commandLink id="sales" target="_blank" value="View Sales Report" action="/Admin/salesreport"/>
<h:commandLink id="employees" target="_blank" value="View Most Active Employees" action="/Admin/activeemployees"/>
<h:commandLink id="customers" target="_blank" value="View Most Active Customers" action="/Admin/activecustomers"/>
<h:commandLink id="movies" target="_blank" value="View Most Active Movies" action="/Admin/activemovies"/>
<br/>
<f:subview id="moviesEditPane">
<span class="#{adminService.getShowMovieClass()}">
Movies.
<ui:repeat value="#{adminService.currentMoviePage}" var="movie">
#{movie.name}
<h:commandLink id="edit" value="Edit">
<f:ajax render="#form" event="click" listener="#{adminService.editMovie(movie.id)}"/>
</h:commandLink>
<h:outputText rendered="#{adminService.movieId eq movie.id}" value="edit"/>
<br/>
</ui:repeat>
</span>
</f:subview>
<f:subview id="employeesEditPane">
<span class="#{adminService.getShowEmployeeClass()}">
Employees.
<ui:repeat value="#{adminService.currentEmployeePage}" var="employee">
#{employee.firstName} #{employee.lastName}
<h:commandLink id="edit" value="Edit">
<f:ajax render="#form" event="click" listener="#{adminService.editEmployee(employee.id)}"/>
</h:commandLink>
<h:outputText rendered="#{adminService.employeeId eq employee.id}" value="edit"/>
<br/>
</ui:repeat>
</span>
</f:subview>
</div>
</f:subview>
<f:subview id="representativeActionPane">
<div class="#{adminService.getShowRepresentativeClass()}">
Customer Representative Pane:
<h:commandLink id="recordOrder" value="Record Order">
<f:ajax render="#form" event="click" listener="#{adminService.toggleOrderPane()}"/>
</h:commandLink>
<h:commandLink id="customers" value="Customers">
<f:ajax render="#form" event="click" listener="#{adminService.toggleCustomerPane()}"/>
</h:commandLink>
<h:commandLink id="mailingList" target="_blank" value="View Mailing List" action="/Admin/mailinglist"/>
<f:subview id="orderPane">
<span class="#{adminService.getShowOrderClass()}">
Create new order.
</span>
</f:subview>
<f:subview id="customerPane">
<span class="#{adminService.getShowCustomerClass()}">
Customers.
<ui:repeat id="customersList" value="#{adminService.currentCustomerPage}" var="customer">
<f:subview id="editCustomer#{customer.id}">
<p class="#{adminService.getEditCustomerClass(customer.id)}">
<h:inputText id="email#{customer.id}" value="#{adminService.customerEmail}"/><br/>
<h:inputText id="firstName#{customer.id}" value="#{adminService.customerFirstName}"/>
<h:inputText id="lastName#{customer.id}" value="#{adminService.customerLastName}"/><br/>
<h:commandButton id="saveEdit#{customer.id}" type="submit" value="Save" actionListener="#{adminService.saveCustomer()}">
<f:ajax render="#form" event="click" execute="#form"/>
</h:commandButton>
<h:commandButton id="cancelEdit#{customer.id}" type="submit" value="Cancel" actionListener="#{adminService.cancelEdit()}">
<f:ajax render="#form" event="click" execute="#form" />
</h:commandButton>
</p>
</f:subview>
<f:subview id="viewCustomer#{customer.id}">
<p class="#{adminService.getViewCustomerClass(customer.id)}">
#{customer.email}<br/>
#{customer.firstName} #{customer.lastName}<br/>
<h:commandLink id="suggestion" target="_blank" value="View Suggestions" action="/Admin/customersuggestions">
<f:param name="user" value="#{customer.id}"/>
</h:commandLink>
<h:commandButton id="edit" type="submit" value="Edit" action="#{adminService.editCustomer(customer)}">
<f:ajax render="#form" event="click" execute="#form" />
</h:commandButton>
</p>
</f:subview>
<br/>
</ui:repeat>
</span>
</f:subview>
</div>
</f:subview>
</h:form>
</div>
</div>
</h:body>
</html>
I found the answer, and the cause of it is really quite strange, but it makes sense.
In my ID's, I was using EL to define unique ID's for UIComponents (even though this was not necessary). When I remove the EL from the ID's, the ajax works!
I'm presuming (though I'm sure BalusC would give a more thorough answer), was that because the id's aren't static, even though the ID in concept would be the same, it was affecting the way JSF finds UIComponents.
Now I feel dumb, because the problem would've been completely avoidable if I didn't add any superfluous elements.
For example, the code in my original post should be as follows:
<h:form id="adminPanel">
...
<f:subview id="editCustomer">
<p class="#{adminService.getEditCustomerClass(customer.id)}">
<h:inputText id="email" value="#{adminService.customerEmail}"/><br/>
<h:inputText id="firstName" value="#{adminService.customerFirstName}"/>
<h:inputText id="lastName" value="#{adminService.customerLastName}"/><br/>
<h:commandButton id="saveEdit" type="button" value="Save">
<f:ajax render="#form" event="click" listener="#{adminService.saveCustomer()}"/>
</h:commandButton>
<h:commandButton id="cancelEdit" type="button" value="Cancel">
<f:ajax render="#form" event="click" listener="#{adminService.cancelEdit()}"/>
</h:commandButton>
</p>
</f:subview>
...
</h:form>
Is there any reason for submitting the form by the Javascript Event onclick?
I suggest you to call the action like this:
<h:commandButton id="saveEdit#{customer.id}" value="Submit" actionListener="#{adminService.saveCustomer()}">
<f:ajax render="#form" execute="#form"/>
</h:commandButton>

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>
<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>
<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"

Resources