The external user edit form

The edit form role

The edit form allow the logged on user to create a new user and edit an existing one.

The edit form can be access from The external users view by clicking on the “Create” button or the properties of an existing user.

The edit form security

The edit form is secured by the security provider implementation configured on the Workplace instance (see The security provider). If the configured security provider dont allow the logged on user to create a user or to edit an existing one, an error message is displayed.

The default edit form configuration

The default XML definition of this edit form in the workplace-navigation.xml is as below :

<form name="workplaceExternalUserAdmin" action="edit" label="LG_USER_DETAILS" information="LG_USER_DETAILS" provider="com.moovapps.workplace.impl.navigation.providers.form.ExternalUserAdminEditProvider" >
    <fields>
        <field name="fldLogin" label="LG_USER_LOGIN"  ctrl="text" mandatory="true"/>
        <field name="fldFirstName" label="common.firstname" ctrl="text" mandatory="true"/>
        <field name="fldLastName" label="common.lastname" ctrl="text" mandatory="true"/>
        <field name="fldEmail" label="common.email" ctrl="com.axemble.vdp.ui.core.document.fields.TextBoxField" mandatory="false"/>
        <!--
        <field name="fldPhoneNumber"  label="directory.user.phone"  ctrl="com.axemble.vdp.ui.core.document.fields.TextBoxField" mandatory="false"/>
        <field name="fldMobilePhoneNumber" label="directory.user.mobile"  ctrl="com.axemble.vdp.ui.core.document.fields.TextBoxField" mandatory="false"/>
        <field name="fldNickName" label="directory.user.nickname" ctrl="com.axemble.vdp.ui.core.document.fields.TextBoxField" mandatory="false"/>
        <field name="fldSex" label="directory.user.sex" ctrl="com.axemble.vdp.ui.core.document.fields.ComboBoxField" mandatory="false"/>
        <field name="fldBirthDate" label="directory.user.birthday" ctrl="com.axemble.vdp.ui.core.document.fields.DateField" mandatory="false"/>
        <field name="fldTitle" label="directory.user.title" ctrl="com.axemble.vdp.ui.core.document.fields.ComboBoxField" mandatory="false"/>
        <field name="fldEmployeeNumber" label="directory.user.employeenumber" ctrl="com.axemble.vdp.ui.core.document.fields.TextBoxField" mandatory="false"/>
        <field name="fldContractType" label="directory.user.contracttype"  ctrl="com.axemble.vdp.ui.core.document.fields.ComboBoxField" mandatory="false"/>
        <field name="fldUserFunction" label="directory.user.function"  ctrl="com.axemble.vdp.ui.core.document.fields.ComboBoxField" mandatory="false"/>
        <field name="fldSocialCategory" label="directory.user.socialcategory"  ctrl="com.axemble.vdp.ui.core.document.fields.ComboBoxField" mandatory="false"/>
        <field name="fldFaxNumber" label="directory.user.fax" ctrl="com.axemble.vdp.ui.core.document.fields.TextBoxField"  mandatory="false"/>
        <field name="fldLanguage" label="common.language" ctrl="com.axemble.vdp.ui.core.document.fields.ComboBoxField" mandatory="false"/>
        <field name="fldAddress1" label="directory.user.address1" ctrl="com.axemble.vdp.ui.core.document.fields.TextBoxField" mandatory="false"/>
        <field name="fldAddress2" label="directory.user.address2" ctrl="com.axemble.vdp.ui.core.document.fields.TextBoxField" mandatory="false"/>
        <field name="fldZipCode" label="directory.user.zipcode" ctrl="com.axemble.vdp.ui.core.document.fields.TextBoxField" mandatory="false"/>
        <field name="fldCity" label="directory.user.city" ctrl="com.axemble.vdp.ui.core.document.fields.TextBoxField" mandatory="false"/>
        <field name="fldCountry" label="directory.user.country"  ctrl="com.axemble.vdp.ui.core.document.fields.TextBoxField" mandatory="false"/>
        <field name="fldDescription" label="common.description" ctrl="com.axemble.vdp.ui.core.document.fields.TextAreaField" mandatory="false"/>
        <field name="fldManager"  label="directory.user.manager" ctrl="com.axemble.vdp.ui.core.document.fields.SingleDirectoryField" type="user" mandatory="false"/>
        <field name="fldAssistant" label="directory.user.assistant" ctrl="com.axemble.vdp.ui.core.document.fields.SingleDirectoryField" type="user" mandatory="false"/>
        <field name="fldHierarchicalManager" label="directory.user.hierarchicalManager"  ctrl="com.axemble.vdp.ui.core.document.fields.SingleDirectoryField" type="user" mandatory="false"/>
        <field name="fldEnable" label="LG_ACTIVE" ctrl="com.axemble.vdp.ui.core.document.fields.CheckBoxField"  mandatory="false"/>
        <field name="fldGroups" label="common.groups" ctrl="selector" screen="directory" type="group" method="select" multiple="true" permissionLevel="WRITE" size="long" />
        <field name="fldActivationDate" label="directory.user.activationDate" description="directory.user.activationDate.description" ctrl="com.axemble.vdp.ui.core.document.fields.DateField" mandatory="false"/>
        <field name="fldExpirationDate" label="directory.user.expirationDate" description="directory.user.expirationDate.description" ctrl="com.axemble.vdp.ui.core.document.fields.DateField" mandatory="false"/>
        -->
    </fields>
</form>

The edit form display four attributes by default : login, firstname, lastname and email.

Override the default External user edit form

All attributes supported by the ExternalUserAdminEditProvider are listed, but some are commented in the workplace-navigation.xml in order to be hidden in the default behaviour.
To add some fields in the form, you must copy the commented lines and insert them in your custom navigation xml file as below

<?xml version="1.0" encoding="ISO-8859-1"?>
<definition name="Custom External users view">
	<screens>
		<view override="workplaceExternalUserAdmin.view" provider="com.moovapps.sample.navigation.providers.view.SampleExternalUserAdminViewProvider">

			<column name="login" label="LG_USER_LOGIN"/>
			<column name="title" label="directory.user.title"/>
			<column name="firstName" label="common.firstname"/>
			<column name="lastName" label="common.lastname"/>
			<column name="email" label="common.email"/>
			<column name="sample" label="LG_SAMPLE"/>

		</view>

		<form override="workplaceExternalUserAdmin.edit">
			<fields>
				<field name="fldLogin" label="LG_USER_LOGIN" ctrl="text" mandatory="true" size="long"/>
				<field name="fldFirstName" label="common.firstname" ctrl="text" mandatory="true"/>
				<field name="fldLastName" label="common.lastname" ctrl="text" mandatory="true"/>
				<field name="fldTitle" label="directory.user.title" ctrl="com.axemble.vdp.ui.core.document.fields.ComboBoxField" mandatory="false"/>
			</fields>
		</form>

	</screens>

</definition>

If you need to add unsupported fields in the form (as extended attribute for example) you wil have to develop your own provider.

For example, if you need to add an extended attribute named sample , you will have to add the field in your custom custom navigation xml file as below :

<form override="workplaceExternalUserAdmin.edit" provider="com.moovapps.sample.navigation.providers.form.SampleExternalUserAdminEditProvider">
    <fields>
        <field name="fldLogin" label="LG_USER_LOGIN" ctrl="text" mandatory="true"  size="long"/>
        <field name="fldFirstName" label="common.firstname" ctrl="text" mandatory="true"/>
        <field name="fldLastName" label="common.lastname" ctrl="text" mandatory="true"/>
        <field name="fldTitle" label="directory.user.title" ctrl="com.axemble.vdp.ui.core.document.fields.ComboBoxField" mandatory="false"/>
        <field name="sample" label="LG_SAMPLE" ctrl="text" mandatory="false"/>
    </fields>
</form>

and implement a formProvider as below :

package com.moovapps.sample.navigation.providers.form;

import com.moovapps.workplace.impl.navigation.providers.form.ExternalUserAdminEditProvider;
import org.apache.commons.lang3.NotImplementedException;
import org.w3c.dom.Element;

import com.axemble.vdoc.sdk.interfaces.runtime.INavigateContext;
import com.axemble.vdp.ui.framework.composites.base.CtlAbstractForm;
import com.axemble.vdp.ui.framework.document.AbstractDocument;
import com.axemble.vdp.ui.framework.document.AbstractField;

public class SampleExternalUserAdminEditProvider extends ExternalUserAdminEditProvider {
	
	public SampleExternalUserAdminEditProvider(INavigateContext context, AbstractDocument document, CtlAbstractForm abstractForm) {
		super(context, document, abstractForm);
	}
	
	@Override
	protected boolean loadCustomField(AbstractField field, Element element) {
		switch (field.getName()){
			case "sample":
				field.setValue(user.getExtendedAttributes().getValue("sample"));
				break;
			case "sample2":
				field.setValue(user.getExtendedAttributes().getValue("sample2"));
				break;
			default:
				throw new NotImplementedException("Field " + field.getName() + "is not implemented!");
		}
		return (true);
	}

	@Override
	protected boolean saveCustomField(AbstractField field) {
		switch (field.getName()){
			case "sample":
				user.getExtendedAttributes().setValue("sample", field.getValue() );
				break;
			case "sample2":
				user.getExtendedAttributes().setValue("sample2", field.getValue() );
				break;
			default:
				throw new NotImplementedException("Field " + field.getName() + "is not implemented!");
		}
		return (true);
	}
}