Very strange behavior p:chips

UI Components for JSF
Post Reply
vished
Posts: 231
Joined: 02 Feb 2014, 17:38

14 Sep 2018, 20:54

Hi all,

It´s very strange for me:
I have a p:chips:

- If I add per "ENTER" key my values will appear in the p:chips as usual. For testing I have also #{emailReceiverInboxController.email.toList} as standalone to see what is in my list...

But I would like to add also an customer emailaddress with a button.
1) If I haven´t ENTERED a value to p:chips my p:overlayPanel will appear.
2) If I have ENTERED a value (per ENTER) my p:overlayPanel will never appear.

3) If I choose 1) and add an emailaddress, it will appear in my #{emailReceiverInboxController.email.toList} but it´s not showing in my p:chips. I have an update over the whole panel, so it should be update also p:chips.

Here my whole code:

Code: Select all

<h:panelGroup id="email_to_panel">
												#{emailReceiverInboxController.email.toList}
													<p:outputLabel for="email_to" value="Empfänger:" />
													<p:chips id="email_to" style="width:100%"
														inputStyle="width:100%" required="false"
														requiredMessage="Bitte Empfänger angeben"
														value="#{emailReceiverInboxController.email.toList}">
														<p:ajax event="itemSelect"
															update=":communicationSendEmailForm:email_to_panel" />
														<p:ajax event="itemUnselect"
															update=":communicationSendEmailForm:email_to_panel" />
													</p:chips>
													<p:tooltip for="email_to" position="top"
														value="Wählen Sie einen Kunden aus oder geben Sie eine Emailadresse an" />
													<p:commandLink id="emailToBtn" value="Kunde auswählen"
														immediate="false" styleClass="Fs12 FontBold"
														global="false" icon="fa fa-font"
														style="margin-right: 10px;" />
													<p:tooltip for="emailToBtn" position="top"
														value="Kunde auswählen" />
												</h:panelGroup>


												<p:overlayPanel id="emailToPanel" for="emailToBtn"
													hideEffect="fade" dynamic="true" dismissable="true"
													showCloseIcon="true"
													style="min-width:650px; max-width:850px; min-height: 150px;">

													<p:dataTable id="customerListDatatable"
														value="#{customerRequestByMandatoryController.lazyModel}"
														var="customer" widgetVar="customerTable"
														multiViewState="false" resizableColumns="false"
														selection="#{customerRequestByMandatoryController.selectedCustomerList}"
														filteredValue="#{customerRequestByMandatoryController.filteredCustomer}"
														rows="10" pageLinks="10" paginatorPosition="bottom"
														lazy="true" paginator="true" reflow="true"
														currentPageReportTemplate="(Eintrag: {startRecord}-{endRecord} von {totalRecords}, Seite: {currentPage} von {totalPages})"
														paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
														rowsPerPageTemplate="10,15,20"
														paginatorAlwaysVisible="false"
														emptyMessage="Kein Kunde gefunden">


														<f:facet name="header">

															<p:outputPanel>
																<p:inputText id="globalFilter"
																	onkeyup="PF('customerTable').filter()" global="false"
																	style="width:250px" placeholder="Suche..." />
															</p:outputPanel>

														</f:facet>


														<p:column sortBy="#{customer.customerNumber}"
															filterBy="#{customer.customerNumber}"
															filterStyle="display:none" visible="true">
															<f:facet name="header">
																<h:outputText value="Kundennummer" />
															</f:facet>
															<h:outputText value="#{customer.customerNumber}" />
														</p:column>


														<p:column sortBy="#{customer.surname}" visible="true"
															filterBy="#{customer.surname}" filterStyle="display:none">
															<f:facet name="header">
																<h:outputText value="Vorname" />
															</f:facet>
															<h:outputText value="#{customer.surname}" />
														</p:column>


														<p:column sortBy="#{customer.name}" visible="true"
															filterBy="#{customer.name}" filterStyle="display:none">
															<f:facet name="header">
																<h:outputText value="Nachname" />
															</f:facet>
															<h:outputText value="#{customer.name}" />
														</p:column>


														<p:column sortBy="#{customer.email}" visible="true"
															filterBy="#{customer.email}" filterStyle="display:none">
															<f:facet name="header">
																<h:outputText value="Email" />
															</f:facet>
															<h:outputText value="#{customer.email}" />
														</p:column>


														<p:column exportable="false">
															<f:facet name="header">
																<h:outputText value="Optionen" />
															</f:facet>

															<div align="center">
																<p:commandButton id="selectCustomerToButton"
																	value="Selektieren" styleClass="green-btn Fs12 White"
																	update=":communicationSendEmailForm:email_to_panel, :growl"
																	icon="fa fa-check" immediate="true"
																	actionListener="#{emailReceiverInboxController.doSelectCustomerTo(customer)}"
																	ajax="true" />
															</div>
															<p:tooltip for="selectCustomerToButton" position="top"
																value="Wählen Sie den Kunden als Empfänger aus" />
														</p:column>


													</p:dataTable>

												</p:overlayPanel>

Backing Bean method:

Code: Select all

	public void doSelectCustomerTo(Customer customer) {

		if (customer.getEmail() == null) {
			FacesContext.getCurrentInstance().addMessage(null,
					new FacesMessage(FacesMessage.SEVERITY_ERROR, "Der Kunde hat keine Emailadresse", ""));
			return;
		}
		List<String> toList = new ArrayList<String>();
		if (email.getToList() != null)
			toList = email.getToList();

		if (toList.contains(customer.getEmail())) {
			FacesContext.getCurrentInstance().addMessage(null,
					new FacesMessage(FacesMessage.SEVERITY_ERROR, "Kunde bereits als Empfänger hinzugefügt", ""));
			return;
		}
		
		if (!toList.contains(customer.getEmail())) {

			toList.add(customer.getEmail());
			email.setToList(toList);
			
			FacesContext.getCurrentInstance().addMessage(null,
					new FacesMessage(FacesMessage.SEVERITY_INFO, "Kunde als Empfänger hinzugefügt", ""));
			return;
		}			
	}
Here from my email ENTITY:
private List<String> toList;
In Firebug I got also no error message. Any ideas?

kukeltje
Expert Member
Posts: 9114
Joined: 17 Jun 2010, 13:34
Location: Netherlands

18 Sep 2018, 09:57

Please try making an 'mcve'... See http://stackoverflow.com/help/mcve
Ronald van Kuijk
______________________________
PrimeFaces 6.1, PrimeFaces plus 0.0.2 | JbossWildfly 10.1| Mojarra 2.2.13
Fedora 61, Firefox 'most recent'
Read the forum posting rules
Beginners: https://jsf.zeef.com/bauke.scholtz

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: Bing [Bot] and 12 guests