Why is the component showing as an input associated with a bean in read mode?

I have a field component in Xpage associated with a bean.
When creating documents, the field appears as an input field, but when reading the document, the component also appears as an input field, why?

+3


source to share


2 answers


If the bean has a getter and setter for a component, then it becomes rendered as an input field.

Use the property of an input field readonly

to determine whether it should be displayed as an input field or as a read-only text field.



    <xp:inputText
        id="inputText1"
        readonly="#{myBean.readOnly}"
        value="#{myBean.myField}">
    </xp:inputText>

      

If you have multiple fields bound to a bean, then a panel with a property surrounds them readonly

. This way you don't need to set this property for every field.

+4


source


I believe you need a method isReadOnly(Object key)

for your bean that handles whether the bean is readonly or not. The isreadOnly () method can base its logic on, for example, an action parameter. Here's a simplified example:

public boolean isReadOnly(final Object key) {
    String action = ExtLibUtil.readParameter(FacesContext.getCurrentInstance(), "action");
    if ("editdocument".equalsIgnoreCase(action)) {
        return false;
    }
    return true;
}

      



The controls then automatically use this to determine whether the inputText control should be displayed in readmode or editmode.

+1


source







All Articles