• Problem with dialog boxes

    By Fredrik Norling 1 decade ago

    If I have a form with a panel and I have a dialogbox with some fields and I want them to be sent to the serverside.

    And I don't want to do a refresh of the page. I added a clientscript to close the dialog and on server side I just added noupdate as refreshmode. Then refresh of the panel (second argument on xsp.closedialog don't work. Probably something with multiple refreshes. Perhaps this can be fixed because there will be developers doing like me ;-)

     

    <?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:button value="Label" id="button2">
    
    <xp:eventHandler event="onclick" submit="false">
    
    <xp:this.script><![CDATA[XSP.openDialog("#{id:Properties}");]]></xp:this.script>
    
    </xp:eventHandler>
    
    </xp:button>
    
    <xp:br></xp:br>
    
    <xp:panel id="data">
    
    <xp:inputText id="test" value="#{viewScope.Name}"></xp:inputText></xp:panel>
    
    <xp:br></xp:br>
    
     
    
    <xp:panel>
    
    <xe:dialog id="Properties" partialRefresh="true"
    
    refreshOnShow="true">
    
    <xp:panel>
    
    <xp:label value="Name:" id="label1"></xp:label>
    
    <xp:inputText id="inputText1" value="#{viewScope.Name}">
    
    </xp:inputText>
    
    <xp:br></xp:br>
    
    <xe:dialogButtonBar id="dialogButtonBar1">
    
    <xp:panel>
    
    <xp:div style="text-align:right">
    
    <xp:button value="Close" id="button1">
    
     
    
    <xp:eventHandler event="onclick"
    
    submit="true" refreshMode="norefresh">
    
    <xp:this.script><![CDATA[XSP.closeDialog('#{id:Properties}','#{id:data}')]]></xp:this.script>
    
    </xp:eventHandler>
    
    </xp:button>
    
    </xp:div>
    
    </xp:panel>
    
    </xe:dialogButtonBar>
    
    </xp:panel>
    
    </xe:dialog>
    
    </xp:panel>
    
    </xp:view>
    
     
    
    • Some comments

      By Philippe Riand 1 decade ago

      So first, if you want the dialog to display the value you entered in the page, it has to submit the value meaning that your button should have a server side behavior:

      <xp:eventHandler event="onclick" submit="true" refreshMode="complete">
      <xp:this.action>#{javascript:var d=getComponent("Properties")
      d.show()}
      ]]>xp:this.action>
      xp:eventHandler>xp:button>

      Then, if you want the value on the page to be updated, you should do the same as well:
      <xp:button value="Close" id="button1">
      <xp:eventHandler event="onclick" submit="true" refreshMode="complete">
      <xp:this.action>#{javascript:var d=getComponent("Properties")
      d.hide("data")}
      ]]>xp:this.action>
      xp:eventHandler>
      xp:button>

       The refresh complete in fact does nothing when the dialog is hidden, so only "data" will actually be refreshed
      This code might also require the latest version of the 853 library (not yet released, but soon :-)) as we took advantage of a new 853 capability to send client script. In the 852 version, the dialog should be part of the refreshed area to be closed, but this is no longer the case.

      Get the latest 853 version when it will be out and let us know if you still have problems.