package org.gluu.oxtrust.action;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;
import javax.inject.Inject;

import org.gluu.model.GluuAttribute;
import org.gluu.service.AttributeService;


@FacesConverter("org.gluu.jsf2.converter.AttributeNameConverter2")
public class AttributeNameConverter2 implements Converter {

	@Inject
	private AttributeService attributeService;
	
	@Override
	public Object getAsObject(FacesContext context, UIComponent component, String value) {
		if (value == null) {
			return null;
		}
		return attributeService.getAttributeByName(value);
	}

	@Override
	public String getAsString(FacesContext context, UIComponent component, Object value) {
		String string = null;
		if (value instanceof GluuAttribute) {
			string = ((GluuAttribute) value).getName();
		}

		return string;
	}

}

@@ -299,17 +299,58 @@
 ervice;%0A
+import org.gluu.service.cdi.util.CdiUtil;
 %0A
-
 %0A@FacesC
@@ -527,10 +527,9 @@
 ce;%0A
-%09
 %0A
+
 %09@Ov
@@ -646,16 +646,16 @@
 null) %7B%0A
-
 %09%09%09retur
@@ -666,16 +666,114 @@
 ll;%0A%09%09%7D%0A
+%09%09if (attributeService == null) %7B%0A%09%09%09attributeService = CdiUtil.bean(AttributeService.class);%0A%09%09%7D%0A
 %09%09return

Configure Registration Form Attributes throws OOPS error #1982