Community articlexFormsModelUpdate method
Added by IBM contributorIBM on August 15, 2011
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars


Updates an XForms model that has been marked for a deferred update. A deferred update is when a data model is flagged to indicate that there are changes that need to be implemented, but the model has not been changed yet.
This method performs the following XForms actions on the given model:


   public void xFormsModelUpdate(
      String modelID,
   ) throws UWIException;


Table 1. Method parameters
modelIDStringThe ID of the model to update. If null or empty, the default model is updated.


Nothing. Throws a UWIException if an error occurs.


The following example shows code from a "shopping cart" application (such as one that might be used for online shopping). The extractXFormsValue method is used to check if the sum of all the values in the shoppingCart element is greater than $100, and if the shipping address of the buyer is located in the continental US. If these conditions are met (the completed parameter returns true), then updateXFormsValue creates an insurance element as a child of the shipping data node, and xFormsModelUpdate updates all of the form data as necessary.
    BooleanHolder completed = new BooleanHolder();
    String pathToForm= "example.xfdl";
    // load form with server-speed + XForms flags
    FormNodeP theForm = this.theXFDL.readForm(pathToForm, XFDL.UFL_SERVER_SPEED_FLAGS_WITH_XFORMS);
    String result = theForm.extractXFormsValue(null, "sum(shoppingCart/line [@toShip]/lineTotal) > 100.0 and address/US/state != 'AK' and address/US/state != 'HI'", null, 0, completed);
    if (completed.value == true && result.equals("true"))
        theForm.updateXFormsValue(null, "instance('shipping')/insurance", null, 0, "@cost", "0.00");

Parent topic:
FormNodeP class