Menu

[Dynamic Forms] Howto switch panel content?

Help
Per Newgro
2003-09-08
2013-05-28
  • Per Newgro

    Per Newgro - 2003-09-08

    Hello,

    I try to use GuiBuilder XML files in a dynamic way and no idea strikes me. Following problem:
    - Use OptionGroup to group two options (OptA, OptB)
    - If OptA is selected, i try to show PanelForOptA
    - If OptB is selected, i try to show PanelForOptB
    Until now I don't have any idea how to do this.
    Use file actual isn't working, cause its not dynamic. I tried OnChange in combination with beanshell-script to, but how can I repaint the panel?
    Is there a simple way to solve my problem?
    THX for help
    Per

     
    • GovObject Development Master

      Try pnuts this way:

      <?xml version='1.0' encoding='ISO-8859-1'?>
      <!DOCTYPE GDL SYSTEM '../gdl.dtd'>
      <GDL>

      <Form>
        <Option label='Option 1' val='true' OnChange='optionChange'/>
        <Date label='Date' name='date1'/>
        <Combo label='Combo' Items='Item1|Item2|Item3' name='combo1'wx='0'/>
        <Option label="Option 2" OnChange='optionChange'/>
        <Option label="Option 3" OnChange='optionChange'/>
      </Form>

      <Script language="pnuts">
      import("de.guibuilder.framework.*")
      import("de.guibuilder.framework.event.*")
      import("javax.swing.Icon")
      import("javax.swing.ImageIcon")

          function optionChange(event)
          {
              myPan = event.component.getGuiParent()
             
              if( event.value == "Option 1" ) {
                  myComp = myPan.getGuiComponent("date1")
                  myComp.setEnabled(true)
                  myComp = myPan.getGuiComponent("combo1")
                  myComp.setEnabled(true)
              }
              else {
                  myComp = myPan.getGuiComponent("date1")
                  myComp.setEnabled(false)
                  myComp = myPan.getGuiComponent("combo1")
                  myComp.setEnabled(false)
              }
          }

      </Script>
      </GDL>

       

Log in to post a comment.

MongoDB Logo MongoDB