0
votes

I have question: My xpages contain a field that contain creator of document. The issue is: When ReadOnly field is Enabled, the agent can't get value of the field from context.

I want user can't change the value of the field How to solve it?

Note: there a button that will call the agent to process the context

Thank you for your help

3
I think this could be due to XPages rendering the readOnly field as text in <span> tag. Some options you can try are - (1) Make readOnly field using JavaScript (2) Make read-only field using attr property (3) Use show read only as disabled property in Xpages (4) Use <xp:inputHidden> control in XPagesNaveen
You need to provide the code. There are no agents in XPages and there is no context in an agentstwissel

3 Answers

1
votes

Why not to use the disable property of the inputText? And with a little help of CSS the result might be just fine:

 <xp:inputText id="inputText1" 
            style="background-color:none;border:none;background: transparent"
            disabled="true">
....
</xp:inputText>

Or you can compute the disable property:

<xp:this.disabled><![CDATA[#{javascript:if (currentDocument.isEditable())
return true;}]]></xp:this.disabled>

Hint: I recommend to create a .css file and write there all the properties. Then just import the file to the respective xpage/custom control and specify the class in the Style property of the field.

1
votes

First of all: it isn't very clear what you want to do. You have a field with the creator of a document and you speak of an agent. A few pointers:

  • Never try to process UI elements. Always go after the data model, the bound data.
  • Displaying a username doesn't write it back anywhere, you need to take a different action. Add to the "post new document" event something like:

    var creator = document1.replaceItemValue("Creator",@UserName);
    creator.setAuthors(true);
    

(above is off my head, might contain typos). Then the value is in the document, you can use it in a computed field and hand it over to an agent (which I wouldn't do, convert your agent code to Java and clean it up while you are on it).

0
votes

Do you mean something like this?

<xp:inputText id="inputText1" defaultValue="test">
        <xp:this.attrs>
            <xp:attr name="readonly" value="true"></xp:attr>
        </xp:this.attrs>
</xp:inputText>