1

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?

Florin M.
  • 2,159
  • 4
  • 39
  • 97
  • 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 Sep 05 '14 at 11:27

1 Answers1

0

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.

Paul Stephen Withers
  • 15,699
  • 1
  • 15
  • 33
  • I add submit="false", but the partial refresh doesn't seem to run anymore. should I modify also the XSP.partialRefreshGet() ? – Florin M. Sep 05 '14 at 11:13
  • What does it show on the Network tab of Firefox (or relevant developer tools for your browser)? That should also confirm if submit="true" was causing a full refresh. – Paul Stephen Withers Sep 05 '14 at 11:16
  • I will have to check. It is strange that this technique worked very well - http://stackoverflow.com/questions/25619967/xpages-hiding-showing-fields-based-on-a-combobox-value/25623177#25623177 - and from now it isn't working anymore. – Florin M. Sep 05 '14 at 11:20
  • It's working there because it's doing a full reload of the page (submit="true"). The partialRefreshGet() is not being run at all. If you use submit="false" the partialRefreshGet runs and only the Render Response phase is triggered. If you use submit="true" all six lifecycle phases run and the partialRefreshGet doesn't run (the first phase logged is Restore View, not Render Response). All those phases will include valildation and if validation fails, the combobox will not be updated. I suggest using SSJS debugger or some other debug tool to see values in your label computation. – Paul Stephen Withers Sep 05 '14 at 12:21
  • When partialRefreshGet runs and Render Response phase is triggered, it's just doing a get, so the combobox value is unchanged as far as the server is concerned. – Paul Stephen Withers Sep 05 '14 at 12:29
  • Thanks for your informations & advices. It seems I will spend some time on this subject. – Florin M. Sep 05 '14 at 12:30
  • Sorry, that was my mistake. Wasn't aware of submit="true". I changed the example to submit="false" and partialRefreshGet() to partialRefreshPost(). – Knut Herrmann Sep 05 '14 at 12:42