Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8194889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:57:38+00:00 2026-06-07T04:57:38+00:00

I am trying to use the extension library component Remote Service ( xe:jsonRpcService ).

  • 0

I am trying to use the extension library component Remote Service (xe:jsonRpcService). I got some hints from here and here. Basically I am trying to save a document using RPC. The problem is that the document gets saved but it does not save any fields present on the XPage. Below is the sample XPage code:

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" xmlns:xe="http://www.ibm.com/xsp/coreex">
    <xp:this.data>
        <xp:dominoDocument var="document1" formName="Test"></xp:dominoDocument>
    </xp:this.data>
    <xe:jsonRpcService id="jsonRpcService1" serviceName="service">
        <xe:this.methods>
            <xe:remoteMethod name="saveDoc">
                <xe:this.script><![CDATA[print(">> " + getComponent("inputText1").getValue());
document1.save();
return true;]]></xe:this.script>
            </xe:remoteMethod>
        </xe:this.methods>
    </xe:jsonRpcService>
    <xp:br></xp:br>
    <xp:inputText id="inputText1" defaultValue="testValue" value="#{document1.testField}"></xp:inputText>
    <xp:br></xp:br>
    <xp:button value="Save" id="button1">
        <xp:eventHandler event="onclick" submit="false">
            <xp:this.script><![CDATA[var deferred = service.saveDoc();
deferred.addCallback(
    function(result) {
        alert(result);
    }
);]]></xp:this.script>
        </xp:eventHandler>
    </xp:button>
</xp:view>

What I have done here is that, I created Remote Service (service) where I am saving the current document (document1). It saves the document but does not save the value in inputText1. Also, when I try to print the value of inputText1 it shows on console but it is not getting saved.

Is this the right way to do it? Or am I missing something here. Also what would be some scenarios where usage of xe:jsonRpcService would be justified?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T04:57:40+00:00Added an answer on June 7, 2026 at 4:57 am

    There are (at least) two reasons for avoiding the use of a JSON-RPC for this type of operation:

    1. This service component is designed to be as lightweight as possible, so, unlike standard events in XPages (which automatically post the entire HTML form), it sends only the data required to call the method, and receives only the data returned by the method. In your example, the method takes no arguments, so it’s literally just sending enough information for the server to know what method to call; similarly, you’re just returning a boolean value, so that’s literally all that will be sent back. If you use your browser’s development tools (i.e. Firebug or the built-in tools in Chrome) to inspect the network traffic, you’ll see this reflected in the JSON packets that are sent in each direction. As a result, the server doesn’t “know” anything that you don’t explicitly “tell” it. So it’s faster than a typical event because you’re not posting anything that isn’t explicitly related to the method you’re calling… but you have to intentionally send everything that the method does need in order to run.
    2. Another side effect of the component’s focus on performance is that it skips the component tree serialization at the end of the JSF lifecycle. If you’re keeping the current page in memory, that shouldn’t be an issue, but if you’re using the default option (save all pages to disk), the server will “forget” any changes that are made to the page during the method invocation. You can explicitly override this behavior on a case-by-case basis by directly telling the view root to serialize its state, but it’s easy to forget that you have to do this manually, which typically causes a lot of frustration when you see indications server-side that it’s doing what it’s supposed to but the actual web page doesn’t reflect that. It’s best to just treat any RPC method as a “read-only” operation unless you’re certain you’ll always remember this odd side effect and understand how to circumvent it.

    My advice is to think of JSON-RPC as “SOAP minus the stupid”. Phrased more politely, it’s conceptually identical to Web Services, but without all the complexity of Web Services. As such, these types of services are ideal for data operations that are useful within the context of the current page without being explicitly tied to the state of the current page.

    Here are some examples of operations where a JSON-RPC method might be useful:

    • Informing a new user whether the user name they’re choosing for their new account is already taken. Instead of binding a standard keyup event which would post the entire form, send only the value of the one field to the service, query it against the site registration records, and send back a boolean.
    • Live polling of related data that is prone to frequent updates. Suppose you’re developing a CRM, and you want to display the stock price of the company whose account you’re viewing. Using setInterval to periodically ask the RPC for the updated stock price, then doing manual client-side DOM manipulation if the price changes, again allows you to perform a somewhat complex operation with a minimum of network overhead.

    This doesn’t mean that you can’t use an RPC for write operations… but for any operation that needs a complete, up-to-date context (i.e. current value of every field on the current page) to run correctly, a standard event handler is nearly always the better approach.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some problem while trying to use the schemagen tool from JAXB library
I'm trying to use mobile controls in a recent extension library. I've setup the
im trying to use a file upload control from the obout control library, i
I am trying to use the Google developer AngularJS library in an extension popup,
I'm trying to create a static library to use inside my PHP extension. To
I'm trying to use thanos, which creates an extension module at runtime. Thanos is
I am trying to make a Firefox extension which will use a webservice. I
I am trying to get JSF setup to use files with a html extension.
I'm trying to install the PECL extension pecl_http so that I can use PHP's
I'm trying to use extensions with Google's Protocol Buffers. I've got one main proto

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.