0

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

  • I think this could be due to XPages rendering the readOnly field as text in `` tag. Some options you can try are - (1) [Make readOnly field using JavaScript](http://naveegator.blogspot.com/2011/12/read-only-edit-box-in-xpage.html) (2) [Make read-only field using `attr` property](http://stackoverflow.com/q/14637693/1047998) (3) [Use show read only as disabled property in Xpages](http://naveegator.blogspot.com/2012/01/new-property-in-xpages-show-read-only.html) (4) Use `` control in XPages – Naveen Nov 24 '14 at 08:35
  • 2
    You need to provide the code. There are no agents in XPages and there is no context in an agent – stwissel Nov 24 '14 at 14:48

3 Answers3

1

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.

Florin M.
  • 2,159
  • 4
  • 39
  • 97
1

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).

stwissel
  • 20,110
  • 6
  • 54
  • 101
0

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>
Chintan Parekh
  • 1,101
  • 1
  • 12
  • 31