cancel
Showing results for 
Search instead for 
Did you mean: 

Field control for label name

fararjeh
Champ in-the-making
Champ in-the-making
Hi,

I want to create field control for "cmis:document.cmis:name" and I well override insertLabel(Writer w_p, String suffix_p,OwFieldDefinition fieldDef_p, String strID_p, boolean writeLabel_p) to change label name .

But I need to determine what is type name of "cmis:document.cmis:name" , Is it from 'departmentPosition' type or 'department' type So how I can get type name in field control ?


<type name="kaad:department">
   <title>Department</title>
   <description>department</description>
   <parent>cm:content</parent>
   <properties>                   
           ……
   </properties>         
</type>   
<type name="kaad:departmentPosition">
   <title>Position</title>
   <description>Job position in the department</description>
   <parent>cm:content</parent>
   <properties>
           ……
   </properties>         
</type>   
4 REPLIES 4

fararjeh
Champ in-the-making
Champ in-the-making
Another way, can I determine type name from objectclass in owbootstrap.xml  by this way :


<FieldControl fieldclass="com.alfresco.ow.server.fieldctrlimpl.label.CustomLabel"
              objectclass="D:kaad:departmentPosition"
         objecttype="cmis:document.cmis:name">
</FieldControl>

d_evil
Champ in-the-making
Champ in-the-making
No that is a misunderstanding of the configuration, and FieldControl's can be configured either for objectclass or objecttype.
objectclass: –> register FieldControl for specific java/value class (like "java.lang.String")
objecttype: –> register FieldControl for a specific Property/Field ECM-ID (like "cmis:document.cmis:name")

Now to your request, which is to control the label depending on the current type.
Well that is basically not possible by design, and the current type is totally hidden for a FieldControl.

But there is a hack possible, based on the context where the FieldControl is called.
[java]
public void insertLabel(Writer w_p, String suffix_p, OwFieldDefinition fieldDef_p, String strID_p, boolean writeLabel_p) throws Exception {
  if (getFieldManager().isFieldProviderType(OwFieldProvider.TYPE_META_OBJECT)){
      Object src = getFieldManager().getFieldProvider().getFieldProviderSource();
      if (src instanceof OwObject) {
          String type = ((OwObject)src).getClassName();
          System.out.println("Current object is from type = " + type);
      }
  }
}
[/java]

fararjeh
Champ in-the-making
Champ in-the-making
Thank you for your reply, About misunderstanding of the configuration I have a custom field control from Workdesk that renders an image if mimetype matches image and a link with icon and name otherwise. Nothing is shown if the reference is null .

Example configuration:


<FieldControl fieldclass="com.alfresco.ow.server.fieldctrlimpl.objectlinkselect.OwObjectSelectFieldControl"
searchtemplate="findImages.xml" objectclass="F:kaad:employee"
objecttype="F:kaad:employee.kaad:employeeImageNoderef">

    <EnabledDocumentFunctions enable="true">
        <pluginid>com.wewebu.ow.owdocprops</pluginid>
    </EnabledDocumentFunctions>
    <columninfo>
        <property>F:kaad:employee.kaad:employeeImageNoderef</property>
    </columninfo>
    <DialogTitle>Select a object from list</DialogTitle>
    <ButtonTitle>Select Object</ButtonTitle>
     <height>80</height>
     <width>80</width>
</FieldControl>

So from this field control configuration I understand
objectclass: –> register FieldControl for specific custom type ECM like (F:kaad:employee )
objecttype: –> register FieldControl for a specific Property/Field ECM-ID (like "cmis:document.cmis:name")

and from OwLastDaysDateControl field control I find javatype tag so Is this tag is responsible for specific java/value class (like "java.lang.String")  ??


  <FieldControl fieldclass="com.wewebu.ow.server.fieldctrlimpl.OwLastDaysDateControl"
       javatype="com.wewebu.ow.server.fieldctrlimpl.OwLastDaysDate" allowNullValue="true">
</FieldControl>


About my request, thank you for your answer It's Working correctly .

d_evil
Champ in-the-making
Champ in-the-making
Yes, right it was javatype, the attribute/configuration
objecttype
was more a feature request from you.
You could try to write an own FieldManager if such requirement is important for you.

But good to hear the hack is working for you.