Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
FormAPI and replicants
work4u
In my DCT I have a replicant which contains a select list thats being populated from a database. The problem I am encountering is I am able to populate only the first field becasue thats open on load. Since the other replicant are collapsed I get a javascript error when its trying to set the field. Also is there's a way to register an event when the replicant is expanded or collapsed.
Appreciate any workarounds.
Find more posts tagged with
Comments
Michael
Hi
Firstly, what version of TeamSite are you on?
How are you populating your select list? Are you using an inline script or formAPI?
If it is using formAPI -- do you need to do it this way? (perhaps because the contents are dynamic based upon another field). If so then you may have a problem.
If you don't need your select list to be dynamic then it would be easier for you to use an inline script.
I don't believe there are any formAPI events when replicants are created or deleted (if that is what you mean by expanded or collapsed?).
I hope this helps but if you provide some more details, attach your DCT, scripts etc then I could provide more assistance.
Cheers
Michael
LooseCannon
>>> Since the other replicant are collapsed I get a javascript error when its trying to set the field.
If the replicant is "collapsed" then it (and any fields within) doesn't exist. Therefore you cannot perform an operation on them.
>>> Also is there's a way to register an event when the replicant is expanded or collapsed.
This has been filed as a Feature Request
work4u
I am using TeamSite version 5.5.2. Yes you are correct, I need to use formAPI because of the dependency on other items, also using in inline script it reads the database for a new DCR and if you update the database with new item and open an existing DCR you do not see the new item in the drop down list.
Michael
Hi
As LooseCannon mentioned there is a feature request open for having formAPI events on replicant creation, moving and deletion. I am pretty sure this hasn't been implemented in 6.0 and I haven't heard of it being included in 6.1 either.
Without these events then you are in a tricky situation. You could consider using a CGI callout to do the same thing - user clicks on a button, new window opens which queries db and displays list. User selects a value and clicks a button - value is posted back to the form. Not as nice a user experience.
btw inline scripts for populating select lists should still work when you edit a DCR. Perhaps you are getting confused with using them for default values?
Hope this helps.
Cheers
Michael
Migrateduser
You actually can trap replicant addition and possibly even the other events. It's not documented and therefore not supported and may not work in future releases (this is 5.5.2). The code looks something like this. Note that the item passed to your handler may not be a normal item with all properties and methods defined (hence the getXPath function). Note that it doesn't seem to matter what your handler returns - even if you return false the instance is added.
function getXPath( item )
{
var xpath = null;
if ( typeof( item.getXPath ) != 'undefined' )
{
xpath = item.getXPath();
}
else
{
xpath = item.getName();
}
return( xpath );
}
function handleItemAdded( item )
{
var xpath = getXPath( item );
if ( xpath.match( '^/container/replicant\\[\\d+\\]$' ))
{
//...
}
}
parent.IWDCEventRegistry.addListener( 'onItemAdded', handleItemAdded );
Michael
Hi
Thanks for the info!
Has anyone implemented this in 6.0 yet?
Does anyone know if this code will work in 6.0?
If not, does anyone have code that does work in 6.0?
Thanks heaps if anyone can help!
Cheers
Michael
work4u
Thanks so much for this valuable info. Is there's an event on the deletion of the replicant like..
parent.IWDCEventRegistry.addListener( 'onItemDeleted', handleItemAdded );
Thanks
Migrateduser
probably but I wouldn't know what it is - you have to reverse engineer using webtool or by looking at the source code.
Bjorn
I just tested it and you can capture the event, but, as John said, regardless of what you return the instance is added, which doesn't suit my purposes. (Prevent certain role from adding add'l instances of a container).
AreaBreakOnCondition.zip
InOutFiles.zip
Migrateduser
I think I had a case like this - I think what I did was hide the container or set all children readonly or something.
Bjorn
For reference purposes, look for a file named dc_action.js in yourservename/httpd/webapps/content_center/formspub. This would be in 6.x only. Don't modify it though. And remember that adding your own event handlers outside of formapi could be a hack, which wouldn't be supported currently or in future versions.
jwl
Just dropping a note to say thanks for the script....
ISCBorisB
Yes, there is. It is actually "Removed", not "Deleted"
Smth like:
parent.IWDCEventRegistry.addListener( 'onItemRemoved', handleItemDelete );
Swap is
parent.IWDCEventRegistry.addListener('onItemsSwapped', handleItemSwap);