p:selectOneListbox, using grouping and p:column

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

23 May 2020, 12:25

Hi,

I´m currently struggeling with the p:selectOneListbox.

It seems I get only the String value, because I got:
The class 'java.lang.String' does not have the property 'value'.
#{diagramElement.value.name} -> it seems get not the diagramElemen....
How can this be fixed? At the end I need the values from "DiagramElement" and grouped by the "SelectItemGroup"

Code: Select all

			<p:selectOneListbox id="diagramElementList"
						converter="diagramElementConverter" 
						var="diagramElement" filter="true" filterMatchMode="contains">

						<f:selectItems
							value="#{availableAutomationComponentControllerView.generateListAvailableElements()}"
							var="diagramElement" itemLabel="#{diagramElement.value.name}"
							itemValue="#{diagramElement}" />

						<p:column style="width: 10px;">
							<div align="center">
								<h:outputText styleClass="#{diagramElement.value.icon} fa-2x" />
							</div>
						</p:column>

					</p:selectOneListbox>


My backend bean:

Code: Select all

	public List<SelectItemGroup> generateListAvailableElements() {

			List<SelectItemGroup> list = new ArrayList<SelectItemGroup>();

			SelectItemGroup g1 = new SelectItemGroup("Test1");
			List<DiagramElement> workflowList = automationElementService.generateListAvailableElements(
					loginBean.getCurrentEmployee(), localeBean.getLanguage(),
					AutomationElementCategory.WORKFLOW.toString());
			g1.setSelectItems(createItemList(workflowList));
			list.add(g1);
			
			return list;

		return null;
	}
	
		private SelectItem[] createItemList(List<DiagramElement> list) {

		List<SelectItem> newlist = new ArrayList<SelectItem>();

		for (DiagramElement e : list) {
			newlist.add(new SelectItem(e, e.getName()));
		}

		SelectItem[] arr = new SelectItem[newlist.size()];
		arr = newlist.toArray(arr);

		return arr;
	}
	
	
PF 8.0

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

23 May 2020, 13:30

Start here: https://stackoverflow.com/questions/684 ... m-database and https://stackoverflow.com/questions/576 ... hdatatable and change your

Code: Select all

generateListAvailableElements()
accordingly

vished
Posts: 479
Joined: 02 Feb 2014, 17:38

23 May 2020, 14:10

Thank you for the links, but that solved not my issue...

If I understood it correctly, if I would like to use the "grouping" functionatly, I have to use: List<SelectItemGroup>
If I return: List<DiagramElement> it´s working as expected, but then I have no grouping...

I´m pretty sure, I have to adjust this code here. Currently I´m getting a String as object, but I need the "DiagramElement":
<f:selectItems
value="#{availableAutomationComponentControllerView.generateListAvailableElements()}"
var="diagramElement" itemLabel="#{diagramElement.name}"
itemValue="#{diagramElement}" />

How can I got this?
PF 8.0

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

24 May 2020, 09:45

I did not state it would solve your problem... They were starting points to remove big errors from your code. If you improved that, than go to the next step and create *and post* a 'MCVE' https://stackoverflow.com/help/mcve (including your converter and a simplified DiagramElement etc so we can 100% see what all actually goes on)

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 26 guests