0

I have an Alfresco community 5.2 installation with a custom form, in this form I have some object finder components, the object-finder component uses hidden fields to keep track of the items you've selected and removed using the picker. A common use for the picker is in the association control. In some cases I have a pre-selected value in the object-finder.

In the image below you can see an example

form example

Examining the div of the picker we can see (I have commented some parts to colorize only the hidden fields)

  • one input named "-" which holds the current picker displayed values,
  • one input named "my_prop-added", which holds added items against the persisted node
  • one input named "my_prop-removed", which holds removed items against the persisted node
    <!--
    <div class="form-field">
        <label for="my-form-alf-id6_prop_myProp-cntrl">Registro:<span class="mandatory-indicator">*</span></label>
      
      <div id="my-form-alf-id6_prop_myProp-cntrl" class="object-finder">
    -->     
         <div id="my-form-alf-id6_prop_myProp-cntrl-currentValueDisplay" class="current-values object-finder-items"><a><div class="itemtype-myc:registriProtocollo"><img src="/share/res/myc/components/images/filetypes/registro-icon16.png" style="border-style:none;" "="" width="16" alt="Registro Ufficiale" title="Registro Ufficiale"> Registro Ufficiale</div></a></div>
            <input type="hidden" id="my-form-alf-id6_prop_myProp" name="-" value="workspace://SpacesStore/3619069f-0740-4a06-8250-20b7767b8588" title="" alf-validation-msg="" class="">
            <input type="hidden" id="my-form-alf-id6_prop_myProp-cntrl-added" name="prop_myProp_added" value="workspace://SpacesStore/3619069f-0740-4a06-8250-20b7767b8588">
            <input type="hidden" id="my-form-alf-id6_prop_myProp-cntrl-removed" name="prop_myProp_removed" value="">
    
            <div id="my-form-alf-id6_prop_myProp-cntrl-itemGroupActions" class="show-picker"><span class="yui-button yui-push-button" id="yui-gen195"><span class="first-child"><button type="button" tabindex="0" id="yui-gen195-button">Seleziona</button></span></span></div>
      </div>
    <!--
    </div>
    -->

When I submit the form an Alfresco java action is called, and I read the form values implementing the addParamDefinition method

@Override
protected void addParameterDefinitions(List<ParameterDefinition> paramList) {
        
        
    paramList.add(new ParameterDefinitionImpl("prop_myProp", DataTypeDefinition.ASSOC_REF, false, null));
    paramList.add(new ParameterDefinitionImpl("prop_myProp_added", DataTypeDefinition.TEXT, false, null));
    paramList.add(new ParameterDefinitionImpl("prop_myProp_removed", DataTypeDefinition.TEXT, false, null));
    // other params ...
}

While I correctly read other added and removed values, I can't get the picker current value inside the java action, I always read null.

I think this happens because the name of the hidden field in the html is "-", while in java is named "prop_myProp".

I can't change the name inside java because in the html form I have multiple pickers and so multiple hidden fields with name="-".

I know I can change the name of the input. but I was wondering if I'm missing some basic Alfresco practice. Why the default name of the picker's current value hidden input is "-"?

Thanks

Fjordo
  • 586
  • 13
  • 34

0 Answers0