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

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

XUI buttons - readonly document

ebheadrick
1-Newbie

XUI buttons - readonly document

Hi,

I have some XUI code that is brought up by the push of a XUI button. Recently the need has come up to opendocuments in readonly mode. I would like to have the XUI button hidden if the document is read only, is this possible?

I have found that I can test for read only and the button will do nothing withjavascript code:

if (Acl.eval("doc_read_only()") > 0 )
{ Application.alert("READ ONLY : Can't edit"); }

But it would be nicer if the button didn't appear at all.

Thanks, Ellen

4 REPLIES 4

Hi Ellen-



You can hide the button by setting its withdraw attribute to "true" if
the document is read only.



--Clay


Hi Clay,

I thought of that.... BUT I wasn't sure how to know the doc was read-only.
This didn't work
<button label="Edit" data&quot;=" disabled="Acl.eval("doc_read_only()")">
What do you use to see if the document is read only besides the
doc_read_only() function? I must be missing something.

Ellen


Clay Helberg <chelberg@terraxml.com> wrote on 11/19/2009 07:53:33 PM:

> Hi Ellen—
>
> You can hide the button by setting its withdraw attribute to “true”
> if the document is read only.
>
> --Clay
>

Hi Ellen—



Right, you can’t use an expression as an attribute value in XUI. You have to use a script to change the value, something like this:



<window height="600" modal="false" orient="horizontal"&lt;br"/>
title="Button Tester" width="400">

<label label="Is" it=" there?-=">"/>

<button id="my_button" label="Button">

</button>

<script ev:event="windowload" type="text/javascript">

// check for read only doc; hide button if so

dlgdoc = Application.event.target.dialogView.document;

doc = Application.activeDocument;

if (Acl.eval("oid_valid(oid_find_valid_insert(oid_root(" + doc.aclId + ")))")==0) {

btn = dlgdoc.getElementById("my_button");

btn.setAttribute("withdraw","true");

}

</script>

</window>



Note that I’m using oid_find_valid_insert() to test whether the doc is writable instead of doc_read_only(), which is notoriously unreliable in detecting read-only status (as the file system understands it).



Hope that helps.



--Clay


All,

In addition to what has been said, the "doc_read_only()" function is not reliable. I turned in a call on it some years ago with Epic 4.3. It worked fine with 4.2.?, but 4.3 or 4.4 broke it. It hasn't worked right since. I can't find the Call # since it was logged when I worked for an organization called FCDIT. I used to use the function extensively to tell the user about cerntain functionality not being available when the user either did not have access to write at the location of the document, or the document had the read-only bit set, or the document was the result of a comparison. All three conditions produced a "1" or true for the function.

When the function was broken, I had to use the "access" function to test the document, which was a lot more combersome in coding.

Anyway, just my 2 cents.

Bob

In Reply to Ellen Headrick:

Hi,

I have some XUI code that is brought up by the push of a XUI button. Recently the need has come up to opendocuments in readonly mode. I would like to have the XUI button hidden if the document is read only, is this possible?

I have found that I can test for read only and the button will do nothing withjavascript code:

if (Acl.eval("doc_read_only()") > 0 )
{ Application.alert("READ ONLY : Can't edit"); }

But it would be nicer if the button didn't appear at all.

Thanks, Ellen

Top Tags