1
votes

In XPages, I have :

  1. one field, id is "ATR_TEST"

  2. one field, id is "inputText32"

  3. a button, id is "button9", value is "Save"

After I input a price on "inputText32" and click the "Save", the price will be shown on "ATR_TEST", the "inputText32" and "Save" will be hidden.

I already complete :

  1. input a price on "inputText32" and click the "Save"

  2. price will show on "ATR_TEST"

  3. "inputText32" and "Save" will hide

Need to do :

Click the "Save" will save this price in the database and leave this document.

The following is "Save"'s code :

var x = getComponent("inputText32").getValue();
getComponent("ATR_TEST").setValue(x);
var a:javax.faces.component.UIComponent = getComponent("inputText32");
var b:javax.faces.component.UIComponent = getComponent("button9");
a.setRendered(false);
b.setRendered(false);

if(getComponent("ATR_TEST").getValue()!= ""){
    document1.save();
}
1
Important: NEVER use get/set value. Too much work. Use Data binding as envisioned by JSF. You bind to a document for values you want to save and to scope variables (there are a few different types) for all others. Any UI stuff draws from there in the spirit of MVC. - stwissel
Please post your code for the fields and buttons in question. You really do not need to do any of the scripting in order to hide a field after entering a value in another field. - teleman
The code for the fields didn't have any code to set. The code for the button is in the question. - Ariel

1 Answers

0
votes

To save a field value in the document, you must enter the document field name for the value:

<xp:inputText
    value="#{document1.ATTR_TEST}"
    id="ATTR_TEST">
</xp:inputText>

That will save the field value in document1.