> hope this helps some, or at least not make things worse :)

He he...

Yeah, thank you.

Is there any way of telling easily which components are stateful (and
therefore need models) and which are not?




On Tue, 2006-09-05 at 00:19 -0700, Igor Vaynberg wrote:
> models are needed because components are stateful. if a component
> lives across requests and data changes the component needs a way to
> display fresh data. this is where the models come in - they allow a
> component to retrieve fresh data. 
> 
> consider the listview - in populate item you create a bunch of labels.
> in the end of request all these labels are disacarded and in the
> beginning of the request these labels are recreated. no need for
> models there because a label doesnt live across requests. 
> 
> now consider the same listview but with reuseitems set to true - that
> means that a label created in populateitem() can potentially live
> across a few requests. now consider this listview is showing a list of
> usernames. at the top of the list is "Bob". user1 is looking at the
> list of users, meanwhile user2 renames "Bob" to "Rob". user1 refreshes
> the page - now if the label used to show the username had no model
> that can refresh itself it would still show "Bob", but if a label had
> a detachable model it would show "Rob" because on the later request
> model.getObject() would return the updated value because it would
> requery the database.
> 
> hope this helps some, or at least not make things worse :)
> 
> -Igor
> 
> 
> 
> 
> On 9/4/06, David Leangen <[EMAIL PROTECTED]> wrote:
>         
>         You're absolutely right! That worked. Thanks!
>         
>         I guess I still don't understand when models need to be used
>         and when
>         simple values are ok.
>         
>         
>         Can somebody explain this to me, or point out some docs?
>         
>         
>         Thank you!
>         
>         
>         
>         
>         On Tue, 2006-09-05 at 12:13 +0530, karthik Guru wrote:
>         > I think having a PropertyModel to access 'isSuccessful'
>         seems complicated.
>         > May be something like this ?
>         >
>         > public class TestLabel extends Label {
>         >
>         >    boolean isSuccessful;
>         >
>         >    public TestLabel( final String id, final String
>         label,boolean isSuccessful){
>         >      super( id, label);
>         >       this.isSuccessful= isSuccessful;
>         >    }
>         >
>         >    @Override
>         >    protected void onComponentTag( final ComponentTag tag ){
>         >      super.onComponentTag( tag );
>         >      final ValueMap map = tag.getAttributes ();
>         >      map.put( "class", getLabelTagClass( isSuccessful ) );
>         >    }
>         > }
>         >
>         > On 9/5/06, David Leangen <[EMAIL PROTECTED]> wrote:
>         > >
>         > > This is exactly what I need. Thanks!
>         > >
>         > > Now, to make the code a bit cleaner in my repeater, I'd
>         like to subclass
>         > > Label, overriding the onComponentTag(ComponentTag) method.
>         I'm a big 
>         > > confused again regarding models...
>         > >
>         > > This is the mess I created, which does not work. The part
>         that confuses
>         > > me the most is the use of the property model in the
>         subclasses Label. 
>         > >
>         > >
>         > >   public class TestLabel
>         > >         extends Label
>         > >   {
>         > >     private static final long serialVersionUID = 1L;
>         > >     private PropertyModel m_isSuccessfulPropertyModel; 
>         > >
>         > >     public TestLabel( final String id, final String label,
>         final
>         > > PropertyModel propModel )
>         > >     {
>         > >       super( id, label );
>         > >       m_isSuccessfulPropertyModel = propModel; 
>         > >     }
>         > >
>         > >     @Override
>         > >     protected void onComponentTag( final ComponentTag
>         tag )
>         > >     {
>         > >       super.onComponentTag( tag );
>         > >       final ValueMap map = tag.getAttributes();
>         > >       final boolean isSuccessful =
>         > > (Boolean)m_isSuccessfulPropertyModel.getObject( this );
>         > >       map.put( "class",
>         getLabelTagClass( isSuccessful ) );
>         > >     }
>         > >   }
>         > >
>         > >
>         > > And I populate my item in the repeater like this.
>         > >
>         > >   add(
>         > >     new DataView( "testResults", new
>         > > TestResultDataProvider( testResults ) ) 
>         > >     {
>         > >       private static final long serialVersionUID = 1L;
>         > >       private boolean m_isSuccessful = true;
>         > >
>         > >       public void populateItem( final Item item ) 
>         > >       {
>         > >         final TestResult testResult =
>         (TestResult)item.getModelObject();
>         > >         final boolean isSuccessful =
>         testResult.isSuccessful();
>         > >         setSuccessful( isSuccessful ); 
>         > >         final PropertyModel isSuccessfulPropertyModel =
>         new
>         > > PropertyModel( this, "isSuccessful" );
>         > >         final Date lastTimeExecuted = new
>         > > Date( testResult.getLastTimeExecuted () );
>         > >         final Long testDuration =
>         testResult.getExecutionTime();
>         > >         item.add( new TestLabel( "test.name",
>         testResult.getName(),
>         > > isSuccessfulPropertyModel ) ); 
>         > >       }
>         > >
>         > >       public void setSuccessful( final boolean
>         isSuccessful )
>         > >       {
>         > >         m_isSuccessful = isSuccessful;
>         > >       }
>         > >
>         > >       public boolean isSuccessful() 
>         > >       {
>         > >         return m_isSuccessful;
>         > >       }
>         > >     }
>         > >   );
>         > >
>         > >
>         > > What am I missing here?
>         > >
>         > >
>         > > 
>         > >
>         > > On Mon, 2006-09-04 at 19:17 -0700, Igor Vaynberg wrote:
>         > > > you can either override oncomponenttag(ComponentTag tag)
>         > > > { tag.getAttributes().get/put } or add a behavior to the
>         component - 
>         > > > namely an (Simple)AttributeModifier.
>         > > >
>         > > > -Igor
>         > > >
>         > > >
>         > > > On 9/4/06, David Leangen <[EMAIL PROTECTED]> wrote:
>         > > >
>         > > >         Could somebody please point me to an example or
>         reference on
>         > > >         how to
>         > > >         dynamically change tag attributes? I don't
>         recall offhand. 
>         > > >
>         > > >         I'm trying to do something like this:
>         > > >
>         > > >         If no error:
>         > > >         <span class="noerr">Righto!</span> 
>         > > >
>         > > >         Or if error:
>         > > >         <span class="err">Sorry, try again!</span>
>         > > >
>         > > >
>         > > >         Thanks!
>         > > >
>         > > >
>         > > >
>         > > >
>         
> -------------------------------------------------------------------------
>         > > >         Using Tomcat but need to do more? Need to
>         support web 
>         > > >         services, security?
>         > > >         Get stuff done quickly with pre-integrated
>         technology to make
>         > > >         your job easier
>         > > >         Download IBM WebSphere Application Server
>         v.1.0.1 based on
>         > > >         Apache Geronimo
>         > > >
>         
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
>         > > >         _______________________________________________
>         > > >         Wicket-user mailing list
>         > > >         Wicket-user@lists.sourceforge.net
>         > > >
>         https://lists.sourceforge.net/lists/listinfo/wicket-user
>         > > >
>         > > >
>         
> ------------------------------------------------------------------------- 
>         > > > Using Tomcat but need to do more? Need to support web
>         services, security?
>         > > > Get stuff done quickly with pre-integrated technology to
>         make your job easier
>         > > > Download IBM WebSphere Application Server v.1.0.1 based
>         on Apache Geronimo
>         > > >
>         
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
>         > > > _______________________________________________
>         Wicket-user mailing list Wicket-user@lists.sourceforge.net
>         https://lists.sourceforge.net/lists/listinfo/wicket-user
>         > >
>         > >
>         > >
>         
> -------------------------------------------------------------------------
>         > > Using Tomcat but need to do more? Need to support web
>         services, security? 
>         > > Get stuff done quickly with pre-integrated technology to
>         make your job easier
>         > > Download IBM WebSphere Application Server v.1.0.1 based on
>         Apache Geronimo
>         > >
>         
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
>         > > _______________________________________________
>         > > Wicket-user mailing list
>         > > Wicket-user@lists.sourceforge.net
>         > > https://lists.sourceforge.net/lists/listinfo/wicket-user
>         > >
>         >
>         >
>         
>         
>         
> ------------------------------------------------------------------------- 
>         Using Tomcat but need to do more? Need to support web
>         services, security?
>         Get stuff done quickly with pre-integrated technology to make
>         your job easier
>         Download IBM WebSphere Application Server v.1.0.1 based on
>         Apache Geronimo 
>         
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
>         _______________________________________________ 
>         Wicket-user mailing list
>         Wicket-user@lists.sourceforge.net
>         https://lists.sourceforge.net/lists/listinfo/wicket-user
> 
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________ Wicket-user mailing list 
> Wicket-user@lists.sourceforge.net 
> https://lists.sourceforge.net/lists/listinfo/wicket-user


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to