DynaForm and selectOneMenu valueItem

Community Driven Extensions Project
Post Reply
pzoli
Posts: 100
Joined: 27 Feb 2012, 20:52
Location: Hungary
Contact:

16 Jul 2016, 14:29

I've an implicite conversion when I get itemValue (Object to String).

Code: Select all

<pe:dynaFormControl type="select" for="select">
    <p:selectOneMenu id="select" value="#{data.value}" required="#{data.required}">
        <f:selectItems var="s" value="#{userManager[data.propertyName]}" itemLabel="#{s[data.detailLabelfield]}" itemValue="#{s}"/>
    </p:selectOneMenu>
</pe:dynaFormControl>
The model of dynaForm is

Code: Select all

    private void initModel() {
        columns = new ArrayList<ColumnModel>();
        formModel = new DynaFormModel();
        DynaFormRow row = formModel.createRegularRow();
        FieldModel model = new FieldModel("photo","hidden",false);        
        DynaFormControl control = row.addControl(model,"hidden");
        
        Class<?> clazz = Clerk.class;
        
		Field[] fields = clazz.getDeclaredFields();
		for (Field field : fields) {
			if (field.isAnnotationPresent(EntityInfo.class)) {
				EntityInfo entityInfo = field.getAnnotation(EntityInfo.class);
				columns.add(new ColumnModel(entityInfo.info(),field.getName()));
								
				row = formModel.createRegularRow();
				DynaFormLabel label = row.addLabel(entityInfo.info());
				FieldModel fmodel = new FieldModel(field.getName(), entityInfo.info(), entityInfo.required());
				if (!entityInfo.detailLabelfield().isEmpty()) {
				    fmodel.setDetailLabelfield(entityInfo.detailLabelfield());
				}
				control = row.addControl(fmodel,entityInfo.editor());				
				label.setForControl(control);
			}
		}
	}
What shoud I do when I'd like get Object and not String?
Please visit my homework on github:
https://github.com/integrityhu/Homework4PFExtDynaForm

The source of whole index.xhtml here
The managed bean code is here
JBoss Developer Studio 11.3.0.GA
Eclipse Oxygen
Wildfly 11
PrimeFaces 6.2.3, PrimaFaces Extensions 6.2.3
Mojarra 2.2.11-jbossorg-1, MyFaces 2.2.8, Deltaspike 1.7.1
MySQL, Oracle, MS-SQL, PostgreSQL, NoSQL

mor
Posts: 48
Joined: 24 Jun 2013, 10:47
Location: Zürich

21 Jul 2016, 10:37

Hi

Maybe add

Code: Select all

converter="#{data.converter}"
to your selectonemenu in the xhtml, the FieldModel will have to have a property get/setConverter... here just return a class which implements "Converter"..

Best Regards

Post Reply

Return to “Extensions”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 3 guests