Hi,

I tried to create a configuration form that has new button to create a
new configuration.

The html:
------------------------------------------------------------------------------------
<html xmlns="http://www.w3.org/1999/xhtml";
xmlns:wicket="http://wicket.sourceforge.net/"; xml:lang="en" lang="en">
<body>
   <wicket:panel>
       <form wicket:id="form">
           <span wicket:id="PIDLabel">[PidLabel]</span>
           <input wicket:id="pid"></input>

           <br/>
           <span wicket:id="factoryPIDLabel">[Factory PID Label]</span>
           <input wicket:id="factoryPid"></input>

           <br/>
           <span wicket:id="bundleLocationLabel">[Bundle Location Label]</span>
           <input wicket:id="bundleLocation"></input>

           <br/>
           <input class="new" type="submit" value="new"
wicket:id="new"></input>
       </form>
   </wicket:panel>
</body>
</html>
------------------------------------------------------------------------------------

The code:
------------------------------------------------------------------------------------
private final class MiniConfigurationForm extends Form
   {

       private final TextField m_pidTextField;
       private final TextField m_facPIDTextField;
       private final TextField m_bdlLocModelTextField;

       private static final String WICKET_ID_PID_LABEL = "PIDLabel";
       private static final String WICKET_ID_PID = "pid";
       private static final String WICKET_ID_FACTORY_PID_LABEL =
"factoryPIDLabel";
       private static final String WICKET_ID_FACTORY_PID = "factoryPid";
       private static final String WICKET_ID_BUNDLE_LOCATION_LABEL =
"bundleLocationLabel";
       private static final String WICKET_ID_BUNDLE_LOCATION =
"bundleLocation";
       private static final String WICKET_ID_DELETE = "delete";
       private static final String WICKET_ID_SAVE = "save";
       private static final String WICKET_ID_NEW = "new";

       private MiniConfigurationForm( String id, PaxConfiguration
configuration )
       {
           super( id );
           CompoundPropertyModel model = new CompoundPropertyModel(
configuration );
           setModel( model );

           Label pidLabel = new Label( WICKET_ID_PID_LABEL, "Pid:" );
           add( pidLabel );

           m_pidTextField = new TextField( WICKET_ID_PID );
           add( m_pidTextField );

           Label factoryLabel = new Label(
WICKET_ID_FACTORY_PID_LABEL, "Factory PID:" );
           add( factoryLabel );

           m_facPIDTextField = new TextField( WICKET_ID_FACTORY_PID );
           add( m_facPIDTextField );

           Label bundleLocation = new Label(
WICKET_ID_BUNDLE_LOCATION_LABEL, "Bundle Location:" );
           add( bundleLocation );

           m_bdlLocModelTextField = new TextField( WICKET_ID_BUNDLE_LOCATION );
           add( m_bdlLocModelTextField );

           NewButton newButton = new NewButton( WICKET_ID_NEW );
           add( newButton );
       }

        ....
        private void setConfiguration( PaxConfiguration paxConfiguration )
       {
           modelChanging();
           m_configuration = paxConfiguration;
           CompoundPropertyModel newModel = new
CompoundPropertyModel( m_configuration );
           setModel( newModel );
       }

       private final class NewButton extends Button
       {

           private NewButton( String id )
           {
               super( id );
           }

           public void onSubmit()
           {
               PaxConfiguration paxConfiguration =
m_confDataProvider.createNewPaxConfiguration();
               MiniConfigurationForm.this.setConfiguration( paxConfiguration );
           }
       }
}
------------------------------------------------------------------------------------

That code works, but if setConfiguration is replaced to any of the following:
1.
    private void setConfiguration( PaxConfiguration configuration )
    {
           // modelChanging(); -- Commented out
           m_configuration = paxConfiguration;
           CompoundPropertyModel newModel = new
CompoundPropertyModel( m_configuration );
           setModel( newModel );

     }
------------------------------------------------------------------------------------
2.
       private void setConfiguration( PaxConfiguration paxConfiguration )
       {
           modelChanging();

           // Copy internal values
           m_configuration.getPid( paxConfiguration.getPid() );

           setModel( getModel() );
       }
------------------------------------------------------------------------------------
Or, with the orginal [setConfiguration(PaxConfiguration
paxConfiguration )] but with [NewButton] to extends [Link]

       private void setConfiguration( PaxConfiguration paxConfiguration )
       {
           modelChanging();

           m_configuration = paxConfiguration;
           CompoundPropertyModel newModel = new
CompoundPropertyModel( m_configuration );

           setModel( newModel );
       }

    private final class NewButton extends Link
       {

           private NewButton( String id )
           {
               super( id );
           }

           public void onClick()
           {
               PaxConfiguration paxConfiguration =
m_confDataProvider.createNewPaxConfiguration();
               MiniConfigurationForm.this.setConfiguration( paxConfiguration );
           }
       }
------------------------------------------------------------------------------------
The form values are NOT updated with the assigned paxConfiguration.

Is this the how is [Form] intended to be used or a bug?

Regards,
Edward Yakop

Note: The code can be checkout from
https://scm.ops4j.org/repos/ops4j/projects/pax/config-admin
and
./agent/wicket/browser/src/main/java/org/ops4j/pax/cm/agent/wicket/configuration/browser/MiniEditConfigurationPanel.java


-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to