1
votes

I have some headaches lately with partial refreshes.

the combobox fires a partial refresh to a panel ( for rendering a field from that panel ), on the onChange event:

    <xp:comboBox value="#{Contr.txt_tipcontractcv}" id="txt_tipcontractcv1">

        <xp:selectItems id="selectItems1">
                        <xp:this.value><![CDATA[#{javascript:return ""}]]></xp:this.value>
        /xp:selectItems>
        <xp:selectItems id="selectItems2">
                        <xp:this.value><![CDATA[#{javascript:@DbColumn(@DbName(),"SetupvwTipuriContracteC",1);}]]></xp:this.value>
        </xp:selectItems>
        <xp:eventHandler event="onchange" submit="true">
                    <xp:this.script><![CDATA[XSP.partialRefreshGet("#{id:FisaP}", {

    });
    ]]>             </xp:this.script>
        </xp:eventHandler>
</xp:comboBox>

And the code for the panel & the field:

<xp:panel id="FisaP">
            <xp:label id="label4">
                <xp:this.value><![CDATA[#{javascript:"Fisa contract "+ Contr.getItemValueString("txt_tipcontractcv1")}]]></xp:this.value>
                <xp:this.rendered><![CDATA[#{javascript:
            Contr.getItemValueString("txt_tipcontractcv1") == "Vanzare-Cumparare"
         }]]></xp:this.rendered>

            </xp:label>
        </xp:panel>

But, when I select a value, the partial refreshes seems to be fired, but immediately the combobox value is null - and a total refresh for the xpage is taken place, and the field from the panel isn't shown. What am I missing?

1
This has nothing to do with your problem/question but I highly recommend you use the style tag as little as possible. You should make a class in a CSS Stylesheet. That's not only a much better web practice but it will also make reading the XSP markup a little easier since there's less overall code there. - David Leedy

1 Answers

0
votes

Your onchange event is doing much more than you anticipate:

  1. XSP.partialRefreshGet() means you're doing a partial refresh of the panel. But because it's a partialRefreshGet(), you're not passing any changes the user is making. So the server doesn't know of any changes the user has made.
  2. submit="true" means it's doing a full refresh of the page after any CSJS you're running. So that's removing anything the user has entered anywhere on the page.

I think you want submit="false" in order to just run your CSJS.

If you want to take into account changes on the browser immediately prior to the onchange running, don't use partialRefreshGet. Instead use:

<xp:eventHandler event="onchange" submit="true" refreshMode="partial" refreshId="FisaP" disableValidators="true">
        </xp:eventHandler>

Converters still run, so if you put e.g. text into a number field, it will still fail.