cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Modify attributes dialog box customization

ptc-2044154
1-Newbie

Modify attributes dialog box customization

Hi Adepters,

I have a requirement of customizing modify attributes dialog box. In this I want to perform some validation on click of OK button. Here is what I have written

Ihave a documentcallback "modify_tag" which in turn adds a callback on dialog item.

doc_add_callback(current_doc(), "modify_tag", "custom_modify_tag_callback");

function custom_modify_tag_callback(doc, oid, win, op)
{

dlgitem_add_callback($win, 'OK','okCB');

}

I am trying to capture ITEM_CHANGED event when user clicks on OK button of modify attributes dialog box and perform some validations on attribute values. Butthis event is never fired.

function okCB(win, dlgitem, event){
if ( event.type == "ITEM_CHANGED") {

# get the attribute value from dialog box and perform the validation.....

}

Please suggest if I am missingsomething here.

Thanks,

Saikrishna



3 REPLIES 3

Has anyone come across the need to validate an attribute after it has
been change/inserted using the out-of-the-box Attribute Dialog? We have
an element with a lang attribute. What we want to happen is to prevent
the document author from entering this element more than once with the
same lang value. For example:

<elementname xml:lang="en">...</elementname>
<elementname xml:lang="fr">...</elementname>

is fine, but

<elementname xml:lang="en">...</elementname>
<elementname xml:lang="fr">...</elementname>
<elementname xml:lang="en">...</elementname>

is not.

We did not want to have to create our own attribute screen and would
prefer to use the OOB screen. We had been trying to perform the check
when the user hits the Ok button, but were not able to trap any event
that would help. Is there some other way to do this? The one issue is
the many places that this attribute can be changed. We are using 5.1 M.

Thanks,
Craig

saikrishna sheshagiri wrote:

> Hi Adepters,
>
> I have a requirement of customizing modify attributes dialog box. In
> this I want to perform some validation on click of OK button. Here is
> what I have written
>
> I have a document callback "modify_tag" which in turn adds a callback
> on dialog item.
>
> doc_add_callback(current_doc(), "modify_tag",
> "custom_modify_tag_callback");
>
> function custom_modify_tag_callback(doc, oid, win, op)
> {
>
> dlgitem_add_callback($win, 'OK','okCB');
>
> }
>
> I am trying to capture ITEM_CHANGED event when user clicks on OK
> button of modify attributes dialog box and perform some validations on
> attribute values. But this event is never fired.
>
> function okCB(win, dlgitem, event){
> if ( event.type == "ITEM_CHANGED") {
>
> # get the attribute value from dialog box and perform the validation.....
>
> }
>
> Please suggest if I am missing something here.
>
> Thanks,
>
> Saikrishna
>
>
>
>
>

Craig,

We have some extensive modifications of the out-of-the-box Attribute Dialog. I'm unsure of whether what we have will be of help to you, but I'll share a pertinent part of it in the hopes that it is.

From your message, it sounds like you're already aware of how to set up a call back for the OK button processing on the attributes dialog, so I'll skip over that.

Here's the ACL code for our OK button processing relating to what we refer to as a help_id attribute. You'll see from the comments within the code that we've found the OK button processing to be messy and somewhat unpredictable business. But what we have works well enough to allow us to avoid having to code up an modify attributes dialog of our own.


#######################################################################
# FUNCTION: helpID_attribute_OK_cb
#
# Handle OK processing
#
# Parameters: win - A handle to the dialog
# dlgitem - The ID of the element
# event - The event
#######################################################################
function helpID_attribute_OK_cb(win, dlgitem, event) {

###########################################
# Currently, there's a big problem with this callback in that the OK button on the Modify Attributes dialog
# does not signal the ITEM_CHANGED event at all over the course of it being clicked on to exit
# the dialog with an OK selection. Instead it only signals the ITEM_FOCUSED and ITEM_UNFOCUSED events
# in an unreliable sequence depending on which other windows are focused or not before and while one actually
# clicks the OK button to exit the dialog. The unpredictable sequnce makes it impossible to accurately detect
# when the user actually clicks the OK button to exit the dialog.
#
# We do know that the OK button will have several spurious ITEM_FOCUSED events occur for it as part of
# starting the dialog and that it seems to be the dialog item that initially receives focus.
# So, to attempt recognizing when the user clicks OK to exit the dialog, we only react to ITEM_FOCUSED
# events which occur after we've once had the OK button lose focus. Then, we validate any non-blank
# value in the helpID field to ensure it doesn't look like an eid value. There are scenarios where
# our validation could be triggered even though the user didn't actually click the OK button. But,
# since we only complain to them about a bad value it shouldn't really matter if we complain a little
# more than we should.


# Just return until we see an ITEM_UNFOCUSED event go by
if (!$XIS_MODATTR_HELPID_OK_UNFOCUSED_EVENT_OCCURRED[win]) {
if (event != "ITEM_UNFOCUSED") {
return;
}
else {

# Set a global variable for this window to remember an unfocused event occurred.
$XIS_MODATTR_HELPID_OK_UNFOCUSED_EVENT_OCCURRED[win] = 1;
return;
}
}

# Now that we've processed an ITEM_UNFOCUSED event, we'll only verify the helpID field value when the OK
# button regains focus.
if (event != "ITEM_FOCUSED") {
return;
}

# Following routine call, verifies help ID value and if bad, warns user and resets value back to a good value.
helpID_attribute_processing(win)

}

Hope this is of help. Feel free to follow up with any questions you may have.

Hi Craig--

I tried sending this reply earlier, but I've been having problems with
my webmail so I don't think it went through.

You might be able to do this using AOM to listen for the DOMAttrModified
event. You could have a function that checks the modified attribute to
make sure it's consistent with the surrounding markup, and revert if not.

Check out the Programmers' Guide (prog_ref.pdf in the /docs directory),
especially chapter 12, for details on event handling in AOM.

--Clay

Craig E Galan wrote:
> Has anyone come across the need to validate an attribute after it has
> been change/inserted using the out-of-the-box Attribute Dialog? We have
> an element with a lang attribute. What we want to happen is to prevent
> the document author from entering this element more than once with the
> same lang value. For example:
>
> <elementname xml:lang="en">...</elementname>
> <elementname xml:lang="fr">...</elementname>
>
> is fine, but
>
> <elementname xml:lang="en">...</elementname>
> <elementname xml:lang="fr">...</elementname>
> <elementname xml:lang="en">...</elementname>
>
> is not.
>
> We did not want to have to create our own attribute screen and would
> prefer to use the OOB screen. We had been trying to perform the check
> when the user hits the Ok button, but were not able to trap any event
> that would help. Is there some other way to do this? The one issue is
> the many places that this attribute can be changed. We are using 5.1 M.
>
> Thanks,
> Craig
>
> saikrishna sheshagiri wrote:
>
>
>> Hi Adepters,
>>
>> I have a requirement of customizing modify attributes dialog box. In
>> this I want to perform some validation on click of OK button. Here is
>> what I have written
>>
>> I have a document callback "modify_tag" which in turn adds a callback
>> on dialog item.
>>
>> doc_add_callback(current_doc(), "modify_tag",
>> "custom_modify_tag_callback");
>>
>> function custom_modify_tag_callback(doc, oid, win, op)
>> {
>>
>> dlgitem_add_callback($win, 'OK','okCB');
>>
>> }
>>
>> I am trying to capture ITEM_CHANGED event when user clicks on OK
>> button of modify attributes dialog box and perform some validations on
>> attribute values. But this event is never fired.
>>
>> function okCB(win, dlgitem, event){
>> if ( event.type == "ITEM_CHANGED") {
>>
>> # get the attribute value from dialog box and perform the validation.....
>>
>> }
>>
>> Please suggest if I am missing something here.
>>
>> Thanks,
>>
>> Saikrishna
>>
>>
>>
>>
>>
>
Announcements