Inside WDK DocbaseObject

Last days I’ve been struggling with the dmfx:docbaseobject in the wdk 5.3.

Because I wanted more control on the layout of the attributes, I choose to create the attributes one by one in the jsp, instead of using the attributelist.

Snippet:

<dmfx:docbaseobject name='current_document' />                        
<tr><td>
<dmfx:docbaseattribute name='attr_obj_id' object='current_document' attribute='r_object_id'  col1="</td><td>" />
</td></tr>
<tr><td>
<dmfx:docbaseattribute name='attr_medewerkercode' object='current_document' attribute='medewerkercode' size='12' col1="</td><td>" />
</td></tr>

This piece of code resides in a component-page. I have created a button that refreshes the page and changes the docbaseobject’s id. When re-rendering, the old values of the attributes remain on the page. This has to do with the internal workings of the DocbaseAttributeValueTag.

The problem lies in the renderEnd code, which does something like this:           

DocbaseAttributeValue value = (DocbaseAttributeValue) getControl();
 
if(obj.isADocbaseObjectInstance())
{
  strValue = value.getValue();
  if(strValue == null)
  {
    IObjectAdapter objectAdapter = obj.getObjectAdapter();
    if(objectAdapter != null)
    {
      strValue = getValueFromObjectAdapter(objectAdapter);
    } else
    {
      strValue = getValueFromDocbaseObject();
    }
    value.setValue(strValue);
    bGotDisplayValuesForRepeatingAttr = true;
  }
}

It acutally reads the value directly from it’s control class. But once the value inside the control class gets set to somethinh other than null, the object is no longer updated.

This is how I worked around it.

I created a extra boolean value “m_reloadFromDocbase” in the control class and in the DocbaseAttribute class, and added these lines in the renderEnd

   if (value.getReloadFromDocbase())
      strValue = null;

This ensures the value of the attribute will get reloaded from the docbase.

In the behaviour class that handles thes jsp, the render-code is a little extended:

                DocbaseAttribute dat = (DocbaseAttribute) getControl( "attr_" + attribute, DocbaseAttribute.class );
                dat.setReloadFromDocbase( true );

The attribute comes form analyzing the page, using a FindValidAttribute visitor. If the boolean is set to false, the filled-in value will remain.

If you are interested in more detail, please dorp me a line [still figuring out howto]

Advertisements

4 Responses to “Inside WDK DocbaseObject”

  1. Nick Says:

    This is interesting. I thought the attribute values can only be controlled from the display attributes in DAB. so if this is done, then what happens to the display attribute list in DAB. Should these attributes exist in that list or is it better to not put them in that list and have them in the JSP. To be frank i have confidence in my code and would like to control as much possible with my code.

  2. robau Says:

    Hi Nick, thanks for your feedback.

    As I have been experimenting with the docbaseattribute, I found out you can arbitrarily add either dmfx:docbaseatrtibute as a single tag, or add
    dmfx:docbaseatrtibutevalue and dmfx:docbaseatrtibutelabel tags to give more flexibility in the way the attributes and their labels are rendered.

    As long as you do not include the list (dmfx:docbaseatrtibutelist) , the settings you used in the DAB (and get published to the data dictionary) are not used.

    If you like all the control, well, here you got it 🙂

  3. Nishant Says:

    Hi,
    This code only set the value in the property page, but not in object. If i take dump of the object, attribute value is ‘0’.

    Can you pls tell me, how i can handle such scenario?

    ishant

    • Nishant Says:

      Hi,
      This code only set the value in the property page, but not in object. If i take dump of the object, attribute value is ‘0′.

      Can you pls tell me, how i can handle such scenario?

      ishant


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: