Nyein Mon Soe
Nyein Mon Soe

Reputation: 129

How can I set the text box as editable when its document mode is readonly in xpages?

To set the edit text as editable when the document mode is readOnly. I add the following code at edit box's readOnly as Computed Field.

var fruitName= sessionScope.get("fruitName");
if(fruitName.equals("Apple") | fruitName.equals("Orange")){
    return false;
}else{
    return true;
}

But the code doesn't work.

Upvotes: 0

Views: 195

Answers (1)

Knut Herrmann
Knut Herrmann

Reputation: 30960

Connect your input text field with a scope variable instead of a document's field.

<xp:inputText 
    id="inputText1" 
    value="#{viewScope.editField}"
    readonly="#{javascript:...}">
</xp:inputText>

By default it will be editable.
You can still compute the readonly property.
You can set a default value for scope variable from a document's fields and you can do with the edited value whatever you want like writing back to current or other document.

Upvotes: 2

Related Questions