i have created a test project here
https://github.com/chongma/myFacesJpa
but in the process of creating the project i figured out the problem.
if i have
FacesContext.getCurrentInstance().addMessage(null,
new FacesMessage(FacesMessage.SEVERITY_ERROR, "Deleted
item", null));
in my method then MyFaces doesn't update any of the "ui:repeat" type
components
This works fine:
FacesContext.getCurrentInstance().addMessage(null,
new FacesMessage(FacesMessage.SEVERITY_INFO, "Deleted
item", null));
i don't know if this is supposed to be like that but it lost me some
time trying to figure it out
On 25/01/2018 17:07, Thomas Andraschko wrote:
Yep you are right. Not sure if there is one available.
But it would be great if you could try it without jpa first.
Am Donnerstag, 25. Januar 2018 schrieb Matthew Broadhead :
when i create these mvce projects i always wonder why there isn't a maven
archetype. in the case of MyFaces maybe a bare bones project with
jetty-maven-plugin, jpa and jsf all preconfigured ready to create a
sample...
On 25/01/2018 16:28, Thomas Andraschko wrote:
In our JIRA: https://issues.apache.org/jira/projects/MYFACES/issues/
A small maven application with jetty-maven-plugin would be a great
example!
2018-01-25 16:24 GMT+01:00 Matthew Broadhead <
matthew.broadh...@nbmlaw.co.uk
:
ok i will do that. where do i create an issue?
On 25/01/2018 16:20, Thomas Andraschko wrote:
Could you please provide a mvce and create a issue?
Otherwise it's almost impossible to help you.
2018-01-25 16:14 GMT+01:00 Matthew Broadhead <
matthew.broadh...@nbmlaw.co.uk
:
hi,
i just posted this question on stack overflow. but then i tested
switching to mojarra and that solved my problem so i guessed i would
report
it to this list
Consider the following xhtml fragment:
<h:form>
<h:outputText value="#{myBean.items.size()}" />
<ui:repeat var="item" value="#{myBean.items}">
<div>
<h:outputText value="#{item.id} #{item.name}" />
<h:commandButton value="delete" action="#{myBean.delete}">
<f:setPropertyActionListener target="#{myBean.item}"
value="#{item}" />
<f:ajax render="@form" />
</h:commandButton>
</div>
</ui:repeat>
<c:forEach var="item" items="#{myBean.items}">
<div>
<h:outputText value="#{item.id} #{item.name}" />
</div>
</c:forEach>
</h:form>
With the backing bean delete method:
@Transactional
public String delete() {
itemDao.delete(getItem());
setItems(itemDao.select());
return null;
}
And the itemDao methods like:
public List<Item> select() {
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Item> cq = cb.createQuery(Item.class);
Root<Item> item = cq.from(Item.class);
cq.distinct(true);
TypedQuery<Item> query = em.createQuery(cq);
List<Item> itemList = query.getResultList();
return itemList;
}
public void delete(Project project) {
project = find(project.getProjectId());
em.remove(project);
}
The problem is that after the delete button is clicked the count is
correct, the c:forEach is correct, but the ui:repeat is not updated and
still shows the deleted element. Can someone suggest how to force the
ui:repeat to also refresh?