I have been trying to follow this showcase example. What I want to do is dynamically add components to a dashboard by clicking buttons on a p:splitButton, the adding of components to the dashboard works, but the panels aren't draggable for some reason. Why?
The XHTML
<!DOCTYPE html>
<html xmlns="http://www.w3c.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:p="http://primefaces.org/ui">
<h:head>
<title>Example</title>
</h:head>
<h:body>
<h:form id="splitButtonForm">
<p:splitButton value="Action" icon="ui-icon-circle-triangle-s">
<p:menuitem value="New text entry" icon="ui-icon-newwin"
actionListener="#{dashboardView.addTextWidget}"
update="dashboardForm:dashboardPanel" />
</p:splitButton>
</h:form>
<h:form id="dashboardForm">
<p:dashboard id="dashboardPanel" model="#{dashboardView.model}">
<p:ajax event="reorder" listener="#{dashboardView.handleReorder}"/>
</p:dashboard>
</h:form>
</h:body>
</html>
And here's the bean
import java.io.Serializable;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import org.primefaces.component.inputtext.InputText;
import org.primefaces.component.panel.Panel;
import org.primefaces.event.DashboardReorderEvent;
import org.primefaces.model.DashboardColumn;
import org.primefaces.model.DashboardModel;
import org.primefaces.model.DefaultDashboardColumn;
import org.primefaces.model.DefaultDashboardModel;
#SuppressWarnings("serial")
#ManagedBean
#ViewScoped
public class DashboardView implements Serializable
{
private DashboardModel model;
public DashboardModel getModel()
{
return model;
}
#PostConstruct
public void init()
{
model = new DefaultDashboardModel();
DashboardColumn column1 = new DefaultDashboardColumn();
DashboardColumn column2 = new DefaultDashboardColumn();
model.addColumn(column1);
model.addColumn(column2);
}
public void addWidget(String widgetId)
{
DashboardColumn column1 = model.getColumn(0);
column1.addWidget(widgetId);
}
public void addTextWidget(ActionEvent event)
{
UIComponent dashboardPanel = FacesContext.getCurrentInstance().getViewRoot().findComponent("dashboardForm:dashboardPanel");
Panel panel = new Panel();
InputText textWidget = new InputText();
int childCount = dashboardPanel.getChildCount();
String widgetId = "widget" + String.valueOf(childCount);
panel.setId(widgetId);
panel.getChildren().add(textWidget);
addWidget(widgetId);
dashboardPanel.getChildren().add(panel);
}
public void handleReorder(DashboardReorderEvent event)
{
}
}
OK then to make the panels draggable the panels header needs to be set, so in the addTextWidget method I had to do something like
panel.setHeader(widgetId);
Related
I have this example code,
My xhtml page.
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
</h:head>
<h:body>
<p:dataList value="#{dataListView.lista}" var="l" type="unordered"
itemType="none" paginator="true" rows="1" styleClass="paginated">
<f:facet name="header">
Paginator
</f:facet>
<p:selectOneRadio id="resposta" value="#{dataListView.resposta}">
<f:selectItem itemLabel="Certo" itemValue="Certo" />
<f:selectItem itemLabel="Errado" itemValue="Errado" />
</p:selectOneRadio>
</p:dataList>
</h:body>
</html>
My Bean
package br.com.so.teste;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.PostConstruct;
import javax.enterprise.context.SessionScoped;
import javax.faces.view.ViewScoped;
import javax.inject.Named;
import br.com.so.modelo.Questao;
#Named
#ViewScoped
public class DataListView implements Serializable {
private List<String> lista;
private String resposta;
#PostConstruct
public void init() {
lista = new ArrayList<>();
lista.add("1");
lista.add("2");
lista.add("3");
lista.add("4");
lista.add("5");
}
public List<String> getLista() {
return lista;
}
public void setLista(List<String> lista) {
this.lista = lista;
}
public String getResposta() {
return resposta;
}
public void setResposta(String resposta) {
this.resposta = resposta;
}
}
The error appear when i change the page view, in pagination have (1,2,3...) if i check the radio button in page '1' and i go to page '2' and i come back to page '1' the radio button is not checked.
Why does it happen?
How do i fix it?
I need to keep the value checked in the radioButtons.
I resolved using this.
I create 2 SelectoneRadio, one geting the checked value, if exists..
And another only puting the value.
I use Ajax to pass the ID.
If the map contains the id, i use ajax only to update, because the radio set the value directly in the map.
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
</h:head>
<h:body>
<h:form id="formulario">
<p:dataList value="#{dataListView.lista}" var="l" type="unordered"
itemType="none" paginator="true" rows="1" styleClass="paginated">
<f:facet name="header">
Paginator
</f:facet>
<p:selectOneRadio value="#{dataListView.teste}"
rendered="#{dataListView.resposta[l] == null}">
<p:ajax listener="#{dataListView.processaResposta(l)}" event="click"
update="formulario"></p:ajax>
<f:selectItem itemLabel="Certo" itemValue="Certo" />
<f:selectItem itemLabel="Errado" itemValue="Errado" />
</p:selectOneRadio>
<p:selectOneRadio value="#{dataListView.resposta[l]}"
rendered="#{dataListView.resposta[l] != null}">
<p:ajax event="click" update="formulario"></p:ajax>
<f:selectItem itemLabel="Certo" itemValue="Certo" />
<f:selectItem itemLabel="Errado" itemValue="Errado" />
</p:selectOneRadio>
</p:dataList>
</h:form>
</h:body>
</html>
And in bean...
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
#ManagedBean
#SessionScoped
public class DataListView implements Serializable {
private List<String> lista;
private Map<String, String> resposta;
private String teste;
#PostConstruct
public void init() {
lista = new ArrayList<>();
lista.add("1");
lista.add("2");
lista.add("3");
lista.add("4");
lista.add("5");
resposta = new HashMap<>();
}
public List<String> getLista() {
return lista;
}
public void setLista(List<String> lista) {
this.lista = lista;
}
public Map<String, String> getResposta() {
return resposta;
}
public void setResposta(Map<String, String> resposta) {
this.resposta = resposta;
}
public void processaResposta(String action) {
resposta.put(action, teste);
teste = null;
}
public String getTeste() {
return teste;
}
public void setTeste(String teste) {
this.teste = teste;
}
}
After put a answer and ID, you need to make the value 'teste' null.
I try to use tag <ace:datatable> inside composite component Mainly it works well. I want to getting row data from the table to use it in bean but when I click on the row, I get error message
Internal server error
I need your help (BalusC :)) to fix this bug.
This is my component:
<?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://xmlns.jcp.org/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:cc="http://java.sun.com/jsf/composite"
xmlns:ace="http://www.icefaces.org/icefaces/components"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:icecore="http://www.icefaces.org/icefaces/core"
xmlns:ice="http://www.icesoft.com/icefaces/component" >
<head>
<title>IGNORED</title>
</head>
<body>
<ui:composition>
<cc:interface componentType="partnercard">
<!-- properties -->
...
</cc:interface>
<cc:implementation>
<div id="#{cc.clientId}">
<ace:dataTable id="partnerTable"
value="#{cc.partnersList}"
binding="#{cc.partnersTable}"
var="partner"
paginator="true"
paginatorPosition="bottom"
rows="10"
style="font-size: 11px;margin-top: 10px;"
selectionMode="single"
stateMap="#{cc.stateMap}" >
<ace:ajax event="select" render="#this" execute="#this" />
<ace:column id="id"
headerText="ID"
sortBy="#{partner.id}"
filterBy="#{partner.id}"
filterMatchMode="contains"
rendered="false">
<h:outputText id="idCell" value="#{partner.id}"/>
</ace:column>
<ace:column id="name"
headerText="Name"
sortBy="#{partner.name}"
filterBy="#{partner.name}"
filterMatchMode="contains">
<h:outputText id="nameCell" value="#{partner.name}"/>
</ace:column>
</ace:dataTable>
</div>
</cc:implementation>
</ui:composition>
</body>
</html>
Component backing bean
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
import javax.faces.application.FacesMessage;
import javax.faces.component.FacesComponent;
import javax.faces.component.NamingContainer;
import javax.faces.component.UIInput;
import javax.faces.component.html.*;
import javax.faces.component.UINamingContainer;
import javax.faces.context.FacesContext;
import javax.faces.component.UIData;
import org.icefaces.ace.model.table.RowStateMap;
#FacesComponent("partnercard")
public class partnercard extends UINamingContainer implements Serializable {
private RowStateMap stateMap = new RowStateMap();
private List<PartnerData> partnersList = new ArrayList<PartnerData>();
private UIData partnersTable; // поиск партнера - таблица со списком партнеров
#Override
public String getFamily() {
return UINamingContainer.COMPONENT_FAMILY;
}
public void encodeBegin(FacesContext context) throws IOException {
super.encodeBegin(context);
}
public UIData getPartnersTable() {
return partnersTable;
}
public void setPartnersTable(UIData partnersTable) {
this.partnersTable = partnersTable;
}
public RowStateMap getStateMap() {
return stateMap;
}
public void setStateMap(RowStateMap stateMap) {
this.stateMap = stateMap;
}
public List<PartnerData> getPartnersList() {
return partnersList;
}
public void setPartnersList(List<PartnerData> partnersList) {
this.partnersList = partnersList;
}
}
This is PartnerData.java
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
public class PartnerData implements Serializable {
private long id = 0;
private String name = "";
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
}
I have created a session bean but it seems my <h:selectOneMenu> is not storing the value in the bean. Can someone tell me what I am doing wrong?
In the xhtml navigates to another xhtml that displays the results. I do not have any values in faces-config.xml other than the navigation rules since I think managed bean / session bean annotations can replace that
xhtml:
<!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:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<!-- Using a custom header -->
<ui:include src="/resources/ADTHeader.xhtml" />
<h:body>
<h1>Test</h1>
<h:form>
<h:selectOneMenu id="mypick"
value="#{gridMaster_backing.pickedGrid}"
converter="#{categoryConverter}"
title="ADTF" >
<f:selectItems value="#{gridMaster_backing.gridList}" var="prog" itemValue="#{prog.gridid}" itemLabel="#{prog.gridid} - #{prog.program} - #{prog.project} - #{prog.ci}" />
</h:selectOneMenu>
<br /><br />
<h:button value="View Grid" outcome="result" />
</h:form>
</h:body>
</html>
Session bean:
package edu.adtf.web;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.ejb.EJB;
import com.ray.adtf.ejb.*;
import com.ray.adtf.jpa.Gridmaster;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
#ManagedBean
#SessionScoped
public class gridMaster_backing {
#EJB
private GridMasterBean ejb;
private Collection<Gridmaster> mgrid;
private List gridList = new ArrayList();
// pickedGrid holds value picked from the gridid drop down list
private Long pickedGrid;
public Long getPickedGrid() {
//System.out.println("getPicked Grid");
return pickedGrid;
//return (long) 100;
}
public void setPickedGrid(Long pickedGrid) {
this.pickedGrid = pickedGrid;
}
// returns data to show grid form
public Collection<Gridmaster> getGridmaster(Long vgridid){
mgrid = ejb.getAllGrids(vgridid);
return mgrid;
}
public void setGridList(List gridList) {
this.gridList = gridList;
}
// list for grid list drop down
public List getGridList() {
List gridList2 = ejb.getDisplayGridList();
return gridList2;
}
}
converter:
package edu.adtf.web;
import javax.faces.bean.ManagedBean;
import edu.adtf.jpa.Gridmaster;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
#ManagedBean(name = "categoryConverterBean")
#FacesConverter(value = "categoryConverter")
public class CategoryConverter implements Converter{
#PersistenceContext
private transient EntityManager em;
#Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
//System.out.println(em.find(Gridmaster.class, new Long(value)));
return em.find(Gridmaster.class, new Long(value));
}
#Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
Gridmaster gridmaster;
gridmaster = (Gridmaster) value;
//System.out.println(String.valueOf(gridmaster.getGridid()));
return String.valueOf(gridmaster.getGridid());
}
}
The problem is in the converter you're using. The field of your managed bean from where you're getting/setting the data is of type Long and the default value for <h:selectOneMenu> is of type String, so you only need to use a Long converter. There's a built-in converter for this case: javax.faces.Long. Make sure you're defining that the itemValue for the <h:selectItems> is type Long as well.
The code should look like this:
<h:selectOneMenu id="mypick"
value="#{gridMaster_backing.pickedGrid}"
converter="javax.faces.Long"
title="ADTF">
<!-- #{prog.gridid} must return Long -->
<f:selectItems
value="#{gridMaster_backing.gridList}"
var="prog"
itemValue="#{prog.gridid}"
itemLabel="#{prog.gridid} - #{prog.program} - #{prog.project} - #{prog.ci}" />
</h:selectOneMenu>
it's my first question on the site :) But first, sorry for my bad english, i'm learning :)
Plz, i need your help. I'm blocked with an application in JSF.
I have this
<?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:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<body>
<ui:composition template="./defaultTemplate.xhtml">
<ui:define name="content">
<h1 style="margin-bottom: 0px">#{msg.default_2}</h1>
<br/>
<ul style="padding-left: 0px">
<ui:repeat value="#{categoryMB.categories}" var="categorie">
<h:outputLabel value=" -==- " style="color: #FF8620; font-size: 10px; padding-left: 0px"></h:outputLabel>
<h:form>
<h:commandLink value="#{categorie.categoryname}" action="#{categoryMB.getItemsByCat(categorie.categoryid.id)}"/>
</h:form>
</ui:repeat>
</ul>
<ui:repeat value="#{categoryMB.listItems}" var="item">
<div class="itemCategory">
<h:graphicImage class="item-image" url="#{item.urlimage}"/>
<h:outputLabel value="#{item.price} €" class="prix"></h:outputLabel>
<br/>
<h2><h:outputLabel value="#{item.name}"></h:outputLabel></h2>
<br/>
<h:form>
<h:commandLink value="#{msg.default_14}" action="#{itemMB.linkItem(item.id)}"
></h:commandLink>
</h:form>
</div>
</ui:repeat>
</ui:define>
</ui:composition>
</body> </html>
Everything is good, except the second commandLink !
I can't execute the action. I always return on the same page...
I tried everything i could and i read all subjects about that on the site but i can't find a solution. Please, i'm asking you, help me. I'm going to be crazy.
My bean for categoryMB :
package managedBean;
import entityBean.Item;
import entityBean.Translatecategory;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.view.ViewScoped;
import sessionBean.ItemFacadeLocal;
import sessionBean.TranslatecategoryFacadeLocal;
/**
*
* #author Aurélien
*/
#ManagedBean
#ViewScoped
public class CategoryMB {
#EJB
private ItemFacadeLocal itemFacade;
#EJB
private TranslatecategoryFacadeLocal translatecategoryFacade;
#ManagedProperty("#{internationalizationMB}")
private InternationalizationMB language;
private List<Item> listItems;
/**
* Creates a new instance of CategoryMB
*/
public CategoryMB() {
}
public List<Translatecategory> getCategories () {
return translatecategoryFacade.findByLanguage(language.getLocale().getLanguage());
}
public void getItemsByCat (int idCat) {
setListItems(itemFacade.findByCat(idCat));
}
public InternationalizationMB getLanguage() {
return language;
}
public void setLanguage(InternationalizationMB language) {
this.language = language;
}
public List<Item> getListItems() {
return listItems;
}
public void setListItems(List<Item> listItems) {
this.listItems = listItems;
}
}
And my bean for itemMB :
package managedBean;
import javax.enterprise.context.SessionScoped;
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
#ManagedBean
#SessionScoped
public class ItemMB implements Serializable {
private int idItem;
/**
* Creates a new instance of ItemMB
*/
public ItemMB() {
}
public int getIdItem() {
return idItem;
}
public void setIdItem(int idItem) {
this.idItem = idItem;
}
public String linkItem(int id)
{
setIdItem(id);
return "item";
}
}
You're mixing CDI #SessionScoped with JSF 2.x #SessionScoped. This is noted in your imports:
import javax.enterprise.context.SessionScoped;
#ManagedBean
#SessionScoped
public class ItemMB implements Serializable {
//...
}
This makes your managed bean to have the default scope, which in JSF 2 is #RequestScoped, so your managed bean will be re created on every request.
Fix your import to:
import javax.faces.bean.SessionScoped;
If you happen to use JSF 2.2.x, start working everything with CDI 1.1. Use #Named for your managed beans and use javax.faces.view.ViewScoped for #ViewScoped.
More info:
What's new in JSF 2.2. CDI compatible #ViewScoped
I've set-up a system which allows you to view categories of IT-equipment and their subcategories.
Now I want to be able to add a subcategory to a parentcategory via JPA.
The problem is that my entity is persisted correctly, but it does not show up in the dataTable. I need to start a new session to make it visible.
This is my xhtml-page:
<?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:f="http://java.sun.com/jsf/core">
<h:head>
<title>Kategorie Tester</title>
<h:outputStylesheet library="css" name="tables.css"/>
<f:metadata>
<f:event type="preRenderView" listener="#{kategorieController.beforeRenderLoadKat}"/>
</f:metadata>
</h:head>
<h:body>
<h:form>
<h:dataTable value="#{kategorieController.reload()}"
var="kat"
styleClass="katview">
<h:column>
<f:facet name="header">
Kategorie
</f:facet>
<h:outputText value="#{kat.titel}"/>
</h:column>
<h:column>
<f:facet name="header">
Unterkategorie
</f:facet>
<h:selectManyCheckbox layout="pageDirection">
<f:selectItems value="#{kat.unterkategorieList}"
var="sub"
itemLabel="#{sub.titel}"
itemValue="#{sub.idunterkategorie}"/>
</h:selectManyCheckbox>
</h:column>
</h:dataTable>
<h:panelGroup>
<h:inputText value="#{kategorieController.titel}"/>
<h:selectOneMenu value="#{kategorieController.kategorie.idkategorie}">
<f:selectItems id="kategorie" value="#{kategorieController.allKats}"
var="kati"
itemLabel="#{kati.titel}"
itemValue="#{kati.idkategorie}"/>
</h:selectOneMenu>
<h:commandButton value="Add" action="#{kategorieController.addSub()}"/>
</h:panelGroup>
</h:form>
</h:body>
</html>
And these are my controllers in order to persist and relaod the data:
KategorieController:
package controller;
import java.io.Serializable;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.event.ComponentSystemEvent;
import javax.inject.Inject;
import model.Kategorie;
import model.Unterkategorie;
#ManagedBean
#SessionScoped
public class KategorieController implements Serializable {
#Inject
private KategorieService katService;
private List<Kategorie> allKats;
// Hinzufügen
private Unterkategorie subkategorie;
private Kategorie kategorie;
private String titel;
public void beforeRenderLoadKat(final ComponentSystemEvent event) {
if (allKats != null) {
allKats.clear();
}
allKats = katService.getAll();
subkategorie = new Unterkategorie();
kategorie = new Kategorie();
}
public void addSub() {
subkategorie.setKategorieId(kategorie);
subkategorie.setTitel(titel);
katService.addSub(this.subkategorie);
}
// GETTERS AND SETTERS
}
KategorieService:
package controller;
import java.io.Serializable;
import java.util.List;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.inject.Inject;
import model.Kategorie;
import model.Unterkategorie;
#Stateless
#TransactionAttribute(TransactionAttributeType.REQUIRED)
public class KategorieService implements Serializable {
#Inject
private KategorieFacade katFacade;
public List<Kategorie> getAll() {
return katFacade.getAll();
}
public List<Kategorie> addSub(final Unterkategorie sub) {
return katFacade.addSub(sub);
}
}
KategorieFacade:
package controller;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
import model.Kategorie;
import model.Unterkategorie;
public class KategorieFacade {
#PersistenceContext
private EntityManager em;
public List<Kategorie> getAll() {
TypedQuery<Kategorie> query = em.createNamedQuery("Kategorie.findAll", Kategorie.class);
return query.getResultList();
}
public List<Kategorie> addSub(final Unterkategorie sub) {
em.persist(sub);
em.flush();
return getAll();
}
}
Any help is appreciated!
Thank you in advance!
Why don't you try to refresh the collection in the addSub() method:
public void addSub() {
subkategorie.setKategorieId(kategorie);
subkategorie.setTitel(titel);
allKats.clear();
allKats.addAll(katService.addSub(this.subkategorie));
}
And completely unrelated to the original question: you're interchanging the concepts Service and Facade with each other.
But I would suggest that instead of putting the getAll() into addSub(), make it void and do another call from the client to the service after doing the insertion.