0
votes

I am using eventhandler on my Xpage to save my datasource (frmData):

<xp:eventHandler
    id="saveEventHandler"
    submit="true"
    save="true"
    event="calledbyid"
    refreshMode="complete"
>
    <xp:this.action><![CDATA[#{javascript:frmData.save();
    context.redirectToPage("index.xsp")}]]></xp:this.action>
</xp:eventHandler>

This is called by custom properites:

<xe:basicLeafNode
onClick="XSP.executeOnServer('#{id:saveEventHandler}')"
label="Save"
rendered="#{javascript:currentDocument.isEditable()}"
>
</xe:basicLeafNode>

That is Mr. Jeremy Hodge code for client to server site trigger:

XSP.executeOnServer = function () {
// must supply event handler id or we're outta here....
if (!arguments[0])
    return false;

// the ID of the event handler we want to execute
var functionName = arguments[0];

// OPTIONAL - The Client Side ID that you want to partial refresh after executing    the event handler
var refreshId = (arguments[1]) ? arguments[1] : "@none";
var form = (arguments[1]) ? this.findForm(arguments[1]) : dojo.query('form')[0];

// catch all in case dojo element has moved object outside of form...
if (!form)
    form = dojo.query('form')[0];

// OPTIONAL - Options object contianing onStart, onComplete and onError functions for the call to the
// handler and subsequent partial refresh
var options = (arguments[2]) ? arguments[2] : {};

// OPTIONAL - Value to submit in $$xspsubmitvalue. can be retrieved using context.getSubmittedValue()
var submitValue = (arguments[3]) ? arguments[3] : '';

// Set the ID in $$xspsubmitid of the event handler to execute
dojo.query('[name="$$xspsubmitid"]')[0].value = functionName;
dojo.query('[name="$$xspsubmitvalue"]')[0].value = submitValue;
this._partialRefresh("post", form, refreshId, options);
}

All fields value on the form has been save except one which is Rich text Item.

When I use simple button onclick event Instead of using above even handler, that Rich text Item saved!!

<xp:button
    value="Label"
    id="button1"
    xp:key="facet_3"
> 
<xp:eventHandler
    event="onclick"
    submit="true"
    refreshMode="complete"
>
    <xp:this.action>
    <xp:saveDocument
    var="frmData"
    >
        </xp:saveDocument>
    </xp:this.action>
</xp:eventHandler>
</xp:button>

Please let me know how to handle this event handler?

-mak

1
How do you call your event handler? - Sven Hasselbach
I add details in my question, please review. - Ashfaq Khatri
Please check this question: stackoverflow.com/questions/17065787/…. It describes what you have to do to save a richtext item with the executeOnServer method. - Sven Hasselbach
Sorry! I am not understand. How can I put that in my code? - Ashfaq Khatri
Before you can execute your server side event you have to update the richtext item. You can do this with the CKEDITOResubmit function in the answer. After updating all CKEditor instances you can fire your event with XSP.executeOnServer. - Sven Hasselbach

1 Answers

0
votes

I don't know if the issue is with the Rich Text Item or the method of submitting. One thing I notice is that you're only passing one parameter to XSP.executeOnServer(), so it's going to infer the submit ID and the submit value.

Can you use Firebug or something similar to check what content is being submitted back to the server, both when you click the button and during the rest of the XPage's life cycle? It's hard to troubleshoot the page lifecycle processes from a question.

If no submit ID or submit value is being passed back to the server, no datasources or components on the page will be updated when you click the button. It will just save the datasource with whatever values were stored against the datasource from previous partial refreshes.

Whenever a partial refresh is triggered, some content will be updated in the server-side map of the XPage. So any previous partial refreshes may update the datasource with values before the XSP.executeOnServer() is triggered. If values have been passed back to the datasource by a partial refresh, those will be saved because they're already in the datasource, not because they are passed again by the XSP.executeOnServer().

If Firebug shows a submit id or submit value that includes the datasource being passed back to the server, the values will be passed back to the datasource, in which case there could be an issue specific to Rich Text Items.