0

Really looking for an idea why my XPage is doing this.

I have field with a dynamic databinding:

<xp:inputText id="CORE_Input" value="#{Document[compositeData.PARA_DataBinding]}"</xp:inputText>

That works quit well until I start to hide it based on a notes formula.

Let me tell what it does: I click a checkbox in my XPage. That checkbox is running SSJS which is calling: Document.getDocument(true) to push the data from my XPage back into the notesdocument without saving it. Once that is done I can use session.evaluate("checkbox!="something"") to hide the inputText field.

It works quit well but the problem is that once I untick the checkbox the value is gone from the inputfield.

If you know a better way to use notes formulas for hiding or the reason why the inputfield is empty once it comes back would be highly appreciated. Here is an example:

<?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:checkBox id="checkBox1" value="#{Document.Check}" text="hide" checkedValue="hide">
    <xp:eventHandler event="onchange" submit="false">
        <xp:this.script><![CDATA[document.getElementById("#{id:hide}").click()]]></xp:this.script>
    </xp:eventHandler>
    </xp:checkBox>
    <xp:panel id="test">
    <xp:inputText id="CORE_Input" type="#{compositeData.NODE}"
        value="#{Document[compositeData.PARA_DataBinding]}"
        defaultValue="#{javascript:compositeData.PARA_DefaultValue}" style="margin-left:24px">
        <xp:this.styleClass><![CDATA[#{javascript:DOMElement.getAttribute("stylesize");}]]></xp:this.styleClass>        <xp:this.rendered><![CDATA[#{javascript:var doc:NotesXspDocument=Document;
        var erg=session.evaluate('Check="hide"',doc.getDocument());
        if(@Text(erg)=="1")
        {return false}
        else
        {return true}}]]></xp:this.rendered>
    </xp:inputText>
    <xp:button value="hide" id="hide">
        <xp:eventHandler event="onclick" submit="true"
            refreshMode="partial" refreshId="test">
            <xp:this.action>
            <![CDATA[#{javascript:var doc:NotesXspDocument=Document;doc.getDocument(true)}]]></xp:this.action>
        </xp:eventHandler></xp:button>
    <xp:button value="unhide" id="unhide">
        <xp:eventHandler event="onclick" submit="true" refreshMode="partial" refreshId="test">
            <xp:this.action><![CDATA[#{javascript:sessionScope.hide=""}]]></xp:this.action>
        </xp:eventHandler></xp:button>
    </xp:panel></xp:view>
user2316219
  • 304
  • 1
  • 11

1 Answers1

0

The problem you have is your default value: As soon the component is unhidden, the value is recalculated. You have to check if the component is partially refreshed. If so, stop the recalculation:

<xp:this.defaultValue>
    <![CDATA[#{javascript:
        importPackage( com.ibm.xsp.ajax );
            if( AjaxUtil.isAjaxPartialRefresh(facesContext) == true ) 
                return;
            compositeData.PARA_DefaultValue
    }]]>
</xp:this.defaultValue>

This should solve your problem

Sven Hasselbach
  • 10,455
  • 1
  • 18
  • 26