Re: Unfriendly Model.ofList etc. methods; can anything be done?

2011-02-13 Thread Willis Blackburn

On Feb 13, 2011, at 2:33 PM, jer...@wickettraining.com [via Apache Wicket] 
wrote:

 I understood your key point, which is why I said as a side note but my 
 point still remains.  Loading a list and then sticking it into Model class 
 is in almost all cases a *bad* idea. 


I agree with you!  But nevertheless there are some cases in which a 
ModelListC makes sense--even when a database is involved.  If, for example, 
the List is small, and is expensive to generate from the database, then 
serializing it and keeping it in the session could be the best approach.


 Sorry, yes, it was early and I wasn't paying attention.  Hadn't had my 
 Wheaties yet :)  Have you looked at the ListModel class?  It may help with 
 what you're looking for. 
 
 Do you have a suggestion for a better method signature for that method?  The 
 problem you are describing, if I understand your description correctly, is a 
 problem with Java generics, not with Wicket's use of them. 


I hadn't seen ListModel, but thanks--it looks like a good solution.  Although 
it sort of makes Model.listOf even more mysterious, in that Model.listOf 
doesn't create a ListModel.

My suggestion for Model.listOf is simply:

public static C IModelListC ofList(final ListC list)

In other words it takes a ListC and return an IModelListC, which is (I 
think) what you'd expect.

Maybe the thinking is that Model.listOf may need to return a list of some 
serializable subclass of C, if C is not serializable itself.

W





-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Unfriendly-Model-ofList-etc-methods-can-anything-be-done-tp3302712p3304062.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Unfriendly Model.ofList etc. methods; can anything be done?

2011-02-12 Thread Willis Blackburn

I'm constantly running into problems with this method:

public static C IModelList? extends C ofList(final List? extends C
list)

This says that ofList takes, as a parameter, a List of C or some subclass of
C, and returns a List of C or of some subclass of C.

The problem that I keep having is that the type of the input list and the
type of the output list may not be the same.  I think that in practice they
are, but the compiler does not know that.  If C = StringedInstrument then
the parameter may be ListViolin while the returned list may be
ListGuitar.

So every time I call Model.listOf, the type parameter of my List becomes
hazy, which has annoying downstream effects.  If I load a
ListStringedInstrument from a database, then pass it to Model.ofList, I
wind up with a List? extends StringedInstrument--the compiler has no idea
what the generic type of the List is, only that whatever it is, it is
compatible with StringedInstrument.  I can still get StringedInstrument
instances out of the List, but I can't pass it to any method (like a
component constructor) that takes a ListStringedInstrument or an
IModelListStringedInstrument without ugly casting.

Since Model.ofList must return a list that is compatible with the original
list--it's a wrapper, not a transformer--can't it just take ListC and
return ListC?

Same goes for the other ofCollection-type methods.

-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Unfriendly-Model-ofList-etc-methods-can-anything-be-done-tp3302712p3302712.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Unfriendly Model.ofList etc. methods; can anything be done?

2011-02-12 Thread Willis Blackburn


jer...@wickettraining.com wrote:
 
 On Sat, Feb 12, 2011 at 7:56 AM, Willis Blackburn wbo...@panix.com
 wrote:
 
 As a side note, rarely should you ever use Model class for a list of
 things,
 especially things loaded from a database.  If you then pass that model to
 a
 component, all the things in it will be serialized.
 
 

I'm sorry that I said that I loaded the list from a database, since that has
apparently created a distraction from my key point, which is that if you
start with a ListC and pass it to Model.listOf, you get back something
that is not a ListC, which is undesirable and perhaps unnecessary.



 So use the Model constructors instead.  The factory methods are just there
 to help remove some verbosity related to generics.
 

Have you tried this yourself?  Because it doesn't work.  You can only
instantiate Model with a Serializable instance, and java.util.List does not
implement Serializable.  The whole point of the ofList method is to generate
serializable lists, and the documentation even says so: This factory method
will automatically rebuild a nonserializable list into a serializable one. 
You're confusing Model.listOf with Model.of.

W


-- 
Jeremy Thomerson
http://wickettraining.com
*Need a CMS for Wicket?  Use Brix! http://brixcms.org*


-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Unfriendly-Model-ofList-etc-methods-can-anything-be-done-tp3302712p3302752.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Is it possible to change the /wicket path?

2011-01-22 Thread Willis Blackburn

(Sorry if this seems familiar to anyone.  I accidentally posted it to the
Nabble Apache Wicket forum the first time, instead of Users.)

I have an application in which the majority of valid URLs map to a content
management system.  In general, anything that's not a bookmarked page or a
Wicket-defined URL goes to the CMS. 

In order to avoid having to list all the possible URLs that the application
itself uses and prohibit users from creating CMS files with those names, I
decided that any URL starting with _ would be reserved by the system.  So
the (bookmarkable) login page is /_login. 

However it looks like I can't change the /wicket path that Wicket itself
uses.  I tracked this down to IMapperContext--but the field itself in
Application and its getter method are both final. 

Is there really no way to change /wicket to something else--like /_wicket? 

Thanks, 
Willis 
-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Is-it-possible-to-change-the-wicket-path-tp3231625p3231625.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



What happened to IValidatorAddListener?

2011-01-22 Thread Willis Blackburn

It has gone missing between 1.5-RC1 and 1.5-M3.  Is there a replacement of
some kind?
-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/What-happened-to-IValidatorAddListener-tp3231645p3231645.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Is it possible to change the /wicket path?

2011-01-22 Thread Willis Blackburn

Thanks!

On Jan 22, 2011, at 5:42 PM, Igor Vaynberg-2 [via Apache Wicket] wrote:

 https://issues.apache.org/jira/browse/WICKET-3368
 
 -igor 
 
 On Sat, Jan 22, 2011 at 9:38 AM, Willis Blackburn [hidden email] wrote:
 
  
  (Sorry if this seems familiar to anyone.  I accidentally posted it to the 
  Nabble Apache Wicket forum the first time, instead of Users.) 
  
  I have an application in which the majority of valid URLs map to a content 
  management system.  In general, anything that's not a bookmarked page or a 
  Wicket-defined URL goes to the CMS. 
  
  In order to avoid having to list all the possible URLs that the application 
  itself uses and prohibit users from creating CMS files with those names, I 
  decided that any URL starting with _ would be reserved by the system.  So 
  the (bookmarkable) login page is /_login. 
  
  However it looks like I can't change the /wicket path that Wicket itself 
  uses.  I tracked this down to IMapperContext--but the field itself in 
  Application and its getter method are both final. 
  
  Is there really no way to change /wicket to something else--like /_wicket? 
  
  Thanks, 
  Willis 
  -- 
  View this message in context: 
  http://apache-wicket.1842946.n4.nabble.com/Is-it-possible-to-change-the-wicket-path-tp3231625p3231625.html
  Sent from the Users forum mailing list archive at Nabble.com. 
  
  - 
  To unsubscribe, e-mail: [hidden email] 
  For additional commands, e-mail: [hidden email] 
  
 
 
 - 
 To unsubscribe, e-mail: [hidden email] 
 For additional commands, e-mail: [hidden email] 
 
 
 
 If you reply to this email, your message will be added to the discussion 
 below:
 http://apache-wicket.1842946.n4.nabble.com/Is-it-possible-to-change-the-wicket-path-tp3231625p3231948.html
 To unsubscribe from Is it possible to change the /wicket path?, click here.


-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Is-it-possible-to-change-the-wicket-path-tp3231625p3232027.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Why I'm getting NPE?

2009-04-29 Thread Willis Blackburn

Hi,

The @SpringBean annotation is only resolved by Component and its  
subclasses.  (Actually it's resolved by SpringComponentInjector--but  
that only works with components.)


You can call InjectorHolder.getInjector().inject(whatever) to resolve  
@SpringBean annotations in the whatever object.


W



On Apr 29, 2009, at 6:38 AM, HHB wrote:


Hey,
I'm trying to employ DataTable in our application.
*
public class SortableContactDataProvider
   extends SortableDataProvider {

   @SpringBean
   private Service service;

   private Group group;

   public SortableContactDataProvider(Group group) {
   if (group == null)
 throw new IllegalStateException(Group is null);
   InjectorHolder.getInjector().inject(this);
   setSort(gsm, true);
   this.group = group;
   }

   public Iterator iterator(int first, int max) {
   return service.list(group, first, max,
   getSort().getProperty(),
   getSort().isAscending()).iterator();
   }

   public int size() {
   return service.listContactsSize(group);
   }

   public IModel model(Object object) {
   Contact contact = (Contact) object;
   return new DomainEntityModelContact
  (Contact.class, contact.getId());
   }

   public void setGroup(Group group) {
   if (group == null)
  throw new IllegalStateException(Group is null);
   this.group = group;
   }

}
*
And I use it this way (inside the panel constructor):
*
Group group = new Group();group.setId(1L);
SortableContactDataProvider scdp = new
  SortableContactDataProvider(group);
   scdp.setGroup(group);
final ListIColumn columns = new ArrayListIColumn();
columns.add(new PropertyColumn(new Model(GSM), gsm, gsm));
AjaxFallbackDefaultDataTable contacts = new
   AjaxFallbackDefaultDataTable(table, columns, scdp, 10);
final WebMarkupContainer wmc = new  
WebMarkupContainer(contactsTable);

wmc.setOutputMarkupId(true);
wmc.add(contacts);
add(wmc);
*
When running the application, I got NullPointerException
from the method size() of the provider, the group object is null.
Why the object is null?
and if it is null, why IllegalStateException is not being thrown?
I'm using Wicket 1.3.5
Thanks for help.


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Validator for 2 fields

2009-04-27 Thread Willis Blackburn

Thorsten,

Look at the Wicket class called EqualInputValidator for guidance.

You have to add it to the form, not to the individual fields.

W


On Apr 27, 2009, at 6:16 AM, Thorsten Scherler wrote:


Hi all,

I have a question about validating one field with another.

I have a form that ask for the start page and for the end page of an
article. I need to validate whether the startPage is lesser or equal  
to

the endPage.

I could do this in public void onSubmit() {...} of the form like:
public void onSubmit() {
if(model.getStartPage()model.getEndPage()){
 this.error(The startPage cannot be bigger then the endPage);
   }
...
}

However I wonder if that is not cleaner with a validator. My problem  
is
ATM that I have not found an example that shows how to validate a  
field

comparing it to another field in the same form.

In pseudo code:

RequiredTextField start = new RequiredTextField(startPage,
Integer.class);
add(start);
RequiredTextField end = new RequiredTextField(endPage,  
Integer.class);


// the next line does not exits but would be what I need

NumberValidator max = NumberValidator.minimum(start);
end.add(max);
add(end);

What is the best way to implement such a validation?

TIA for any tips.

salu2
--
Thorsten Scherler thorsten.at.apache.org
Open Source Java consulting, training and solutions

Sociedad Andaluza para el Desarrollo de la Sociedad
de la InformaciĆ³n, S.A.U. (SADESI)





-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: displaying xml content

2009-04-27 Thread Willis Blackburn

Shiraz,

Does this dynamic XML content include references to Wicket  
components?  In other words does it include wicket:id attributes?


If not, then you don't need a special panel for it.  You can just  
display it as a MultilineLabel with escaping turned off.


W


On Apr 27, 2009, at 5:57 AM, shiraz memon wrote:


Hi
I am trying to display dynamic xml content on simple panel. For that  
I have
also overriden the getMarkupType method with xml as returning  
string in
the XmlPanel class (which extends Panel). Besides that, I have also  
created
an empty XMLPanel.xml file. After viewing the panel on browser I see  
the

following error:
WicketMessage: Tag expected
[markup =
file:/home/shiraz/workspace/iscore/target/classes/is/web/ 
XmlInfoPanel.xml

, index = 1, current = null]

Root cause:

org.apache.wicket.markup.MarkupException: Tag expected
[markup =
file:/home/shiraz/workspace/iscore/target/classes/is/web/ 
XmlInfoPanel.xml

, index = 1, current = null]
at
org 
.apache 
.wicket.markup.MarkupStream.throwMarkupException(MarkupStream.java: 
465)

at org.apache.wicket.markup.MarkupStream.getTag(MarkupStream.java:269)
at
org 
.apache 
.wicket.MarkupContainer.renderAssociatedMarkup(MarkupContainer.java: 
639)

at
org 
.apache.wicket.markup.html.panel.Panel.onComponentTagBody(Panel.java: 
114)

at org.apache.wicket.Component.renderComponent(Component.java:2596)
at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java: 
1521)

at org.apache.wicket.Component.render(Component.java:2421)
at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java: 
1399)

at
org 
.apache 
.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java: 
1586)

at
org 
.apache 
.wicket.MarkupContainer.onComponentTagBody(MarkupContainer.java:1510)

at org.apache.wicket.Component.renderComponent(Component.java:2596)
at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java: 
1521)

at org.apache.wicket.Component.render(Component.java:2421)
at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java: 
1399)

at
org 
.apache 
.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java: 
1586)

at
org 
.apache 
.wicket.MarkupContainer.onComponentTagBody(MarkupContainer.java:1510)

at org.apache.wicket.Component.renderComponent(Component.java:2596)
at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java: 
1521)

at org.apache.wicket.Component.render(Component.java:2421)
at  
org.apache.wicket.markup.html.list.ListView.renderItem(ListView.java: 
635)

at
org 
.apache.wicket.markup.html.list.ListView.renderChild(ListView.java: 
623)

at
org 
.apache 
.wicket 
.markup.repeater.AbstractRepeater.onRender(AbstractRepeater.java:103)

at org.apache.wicket.Component.render(Component.java:2421)
at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java: 
1399)
at org.apache.wicket.MarkupContainer.renderAll(MarkupContainer.java: 
1537)

at org.apache.wicket.Page.onRender(Page.java:1522)
at org.apache.wicket.Component.render(Component.java:2421)
at org.apache.wicket.Page.renderPage(Page.java:926)
at
org 
.apache 
.wicket 
.request 
.target 
.component 
.BookmarkablePageRequestTarget 
.respond(BookmarkablePageRequestTarget.java:262)

at
org 
.apache 
.wicket 
.request 
.AbstractRequestCycleProcessor 
.respond(AbstractRequestCycleProcessor.java:105)

at
org 
.apache 
.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1200)

at org.apache.wicket.RequestCycle.step(RequestCycle.java:1271)
at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1370)
However, the error is about the empty xml file. Since the content is
generated at runtime from some external source, is there a way to  
view that

dynamic xml content in wicket panel?
Thanks
Shiraz



-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Large Scale Applications using Wicket

2009-03-13 Thread Willis Blackburn

I don't think that page serialization is going to be your bottleneck.

I don't know what you're thinking when you say large scale.  Some  
folks think large scale means two server and others think  
Travelocity or Google.  I developed a system in PHP that served about  
20-50 pages per second.  This was PHP 4.  I don't know if things are  
different now, but in PHP 4, the PHP module interpreted every PHP page  
from scratch, loaded the session state from disk, rendered the page,  
and wrote the session state back to disk, with every request.  The  
time required to serialize the session to the disk and read it back  
every time was negligible.


I suggest you write your Wicket app first, then analyze the  
performance and determine what you need to optimize.  It almost  
certainly won't be the serialization.  It will be your own code:   
mostly database access and synchronized blocks.


W



On Mar 12, 2009, at 11:52 PM, subbu_tce wrote:



Do we have any Clustering Solutions other than Terracotta that can  
integrate

with Wicket to avoid serialization of pages to support development of
applications in a large scale?

Thanks,
Subbu.
--
View this message in context: 
http://www.nabble.com/Large-Scale-Applications-using-Wicket-tp22489752p22489752.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Two Wicket Apps in a single web app

2009-03-13 Thread Willis Blackburn
Sure.  You just have to sort out the URL space so they don't  
conflict.  Mount a bunch of Wicket filters on various URLs, each  
referencing a different Application instance.


W

On Mar 13, 2009, at 9:46 PM, subbu_tce wrote:



Is it possible to two or more wicket apps in a single web appliation?
--
View this message in context: 
http://www.nabble.com/Two-Wicket-Apps-in-a-single-web-app-tp22508361p22508361.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Why is BookmarkablePageLink generified?

2009-03-02 Thread Willis Blackburn

BookmarkablePageLink isn't final.  A subclass could use the model.

W

On Mar 2, 2009, at 7:36 AM, Erik van Oosten wrote:


Hello,

I was wondering why BookmarkablePageLink has been generified. A  
bookmarkable link has no use for a model as far as I can see.


Shall I create an issue to change the declaration of  
BookmarkablePageLink from:

  public class BookmarkablePageLinkT extends LinkT
to
  public class BookmarkablePageLink extends LinkVoid
?

Regards,
  Erik.

--
Erik van Oosten
http://day-to-day-stuff.blogspot.com/



-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: bad practice in sharing models between wicket form and hibernate?

2009-03-01 Thread Willis Blackburn
Let's say you have a Java object with 20 fields that's mapped to a  
database using Hibernate.  I don't see that there's much difference in  
terms of memory utilization between using that object as the model and  
creating a separate object with 20 fields to use as the model.   
Following the principle of not repeating yourself, I'd say that  
everything else being equal, it makes more sense to use the persistent  
object.  Of course there will always be fields that you don't want to  
be set directly from the form, but you can use Brill's strategy of  
wrapping the persistent object in another object that just contains  
the fields for which you want to implement some extra logic.


There's a subtle difference between having the model reload the  
persistent object every time and just keeping a hard reference to it  
that is worth mentioning.  If you keep a hard reference to the  
persistent object, and you're using Hibernate's version or timestamp  
feature, and you actually merge the object back into the session  
rather than copy the fields to a newly-loaded object, then Hibernate  
will be able to detect cases in which the user is trying to save edits  
to a stale version of the object.  This isn't always useful, but it  
might be, depending on your requirements.


W



On Mar 1, 2009, at 5:09 AM, Johan Compagner wrote:


You shouldnt put that object directly in a CPM, but have a loadabled
detachable model in between. Because now you probably have that hib
object in the page between requests

On 28/02/2009, Stephen Swinsburg s.swinsb...@lancaster.ac.uk wrote:

Hi all,

I'm after your thoughts on the following method.

Suppose there is a wicket form with some fields that can map directly
to a simple Hibernate object, and hence a db table. Is it safe to
simply wrap this object in a CompoundPropertyModel and use it as the
backing model for the form?
Then in the onSubmit method, calling a method to get the object from
the form's model and saving it via Hibernate.

This does work fine, I'm just after any pitfalls that might happen
down the track. Very simple form here.

thanks.
S

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: bad practice in sharing models between wicket form and hibernate?

2009-03-01 Thread Willis Blackburn

Johan,

I was trying to say, in a confused kind of way, that standard practice  
is to back a form up with a bean of some kind, and that replacing that  
bean with a persistent object wouldn't necessarily increase memory  
utilization enough to bother with a detached model.  On the other hand  
if the persistent object had lots of references to other objects then  
maybe detaching it would be a good idea.  On the other hand, if the  
form uses lots of AJAX, then it might not be worth reloading the  
persistent object every time a request comes in.  I suppose that the  
best approach depends on the requirements.


W



On Mar 1, 2009, at 9:00 AM, Johan Compagner wrote:


i didnt say you have to have a different object.
I just say dont keep persistent objects in memory between requests.  
Use

detachable for that.

The only exception i guess is when you create a new object that isnt
persisted yet to the db and you have some kind of wizard to fill it  
up.


On Sun, Mar 1, 2009 at 14:56, Willis Blackburn wbo...@panix.com  
wrote:


Let's say you have a Java object with 20 fields that's mapped to a  
database
using Hibernate.  I don't see that there's much difference in terms  
of
memory utilization between using that object as the model and  
creating a
separate object with 20 fields to use as the model.  Following the  
principle
of not repeating yourself, I'd say that everything else being  
equal, it
makes more sense to use the persistent object.  Of course there  
will always
be fields that you don't want to be set directly from the form, but  
you can
use Brill's strategy of wrapping the persistent object in another  
object
that just contains the fields for which you want to implement some  
extra

logic.

There's a subtle difference between having the model reload the  
persistent
object every time and just keeping a hard reference to it that is  
worth
mentioning.  If you keep a hard reference to the persistent object,  
and
you're using Hibernate's version or timestamp feature, and you  
actually
merge the object back into the session rather than copy the fields  
to a
newly-loaded object, then Hibernate will be able to detect cases in  
which
the user is trying to save edits to a stale version of the object.   
This

isn't always useful, but it might be, depending on your requirements.

W




On Mar 1, 2009, at 5:09 AM, Johan Compagner wrote:

You shouldnt put that object directly in a CPM, but have a loadabled

detachable model in between. Because now you probably have that hib
object in the page between requests

On 28/02/2009, Stephen Swinsburg s.swinsb...@lancaster.ac.uk  
wrote:



Hi all,

I'm after your thoughts on the following method.

Suppose there is a wicket form with some fields that can map  
directly

to a simple Hibernate object, and hence a db table. Is it safe to
simply wrap this object in a CompoundPropertyModel and use it as  
the

backing model for the form?
Then in the onSubmit method, calling a method to get the object  
from

the form's model and saving it via Hibernate.

This does work fine, I'm just after any pitfalls that might happen
down the track. Very simple form here.

thanks.
S

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org





-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Add a surrounding component to itself

2009-02-17 Thread Willis Blackburn

Prag,

It would be tough to write a component that could replace itself,  
and I think that it's impossible to have a component that's visible  
when its parent is invisible.


What you want to do is create a Panel that either displays the link  
with the product within it, or just displays the product.  You'll  
probably want to use Fragment within the Panel, which will let you use  
a different bit of markup for each case while still keeping it in one  
HTML file.  You could also just create the components for both cases  
(a standalone Label and a Link containing a second Label) and just  
show one or the other.


W


On Feb 17, 2009, at 5:37 PM, Prag wrote:



For a component (A) I would like to be able to add a surrounding  
component

(B) (a link) in some cases. Component A itself should be able to add
surrounding component B.

Example:
A product component in some cases has detailed info. If this is the  
case,

the product component should be linkable to the detailed page. If it's
linkable, the product component should add a surrounding link to  
itself to

the detailed page.


So the product component should be able to hide/add its parent without
itself become hidden.

How can I achieve this?
--
View this message in context: 
http://www.nabble.com/Add-a-surrounding-component-to-itself-tp22067906p22067906.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: N-level CompoundPropertyModel

2009-02-16 Thread Willis Blackburn

Johan,

The below solution requires that SmallComponent know it's parent has  
CompoundPropertyModel and that there is a member called  
smallObject.  I'm trying to keep SmallComponent generic, like the  
Wicket built-in components.


W


On Feb 16, 2009, at 2:46 PM, Johan Compagner wrote:


yes initmodel shouldnt call getModel() on the parent
because that was a big performance penalty on some solutions because  
that

would create and walk over the complete hierarchy of things
and then many many in between models are created, that dont do really
anything.

But why not something like this:

public class BigPage {
 public BigPage(BigObject object) {
 setModel(new CompoundPropertyModel(object));
  add(new SmallComponent(smallObject, getModel()));
 }
}

public class SmallComponent {
  public SmallComponent(CompoundPropertyModel model) {
  add(new Label(name, model.bind(smallObject.name));
}
}

johan


On Mon, Feb 16, 2009 at 05:50, Igor Vaynberg  
igor.vaynb...@gmail.comwrote:



hrm, looks like johan changed it here

526472  4/7/07 12:13 PM 3   jcompagner  component initModel  
will

not call
getModel on the parent, but will directly use the field (so that not
all kinds of inbetween models are created) if model is an iwrapmodel
and the wrapped modes is an inherited one then the model will be
cleared on detach Compound.getTarget() removed. Compound will not
unwrap in getObject() anymore AbstractPropertyModel will unwrap until
all models are processed

seems to me that the change breaks what i thought the contract of
initmodel was... we should discuss on dev, mind sending a message?

-igor


On Sun, Feb 15, 2009 at 10:08 AM, Willis Blackburn wbo...@panix.com
wrote:

Igor,

Are you sure that will work?  I don't think that SmallComponent's

initModel

method is ever called, because when the Label that is part of

SmallComponent

is searching for a model (in Component.initModel), it invokes the
getModelImpl method of SmallComponent, which doesn't call initModel.

(The
comment in the code says Don't call getModel() that could  
initialize

many

in-between useless models.

W

On Feb 15, 2009, at 12:23 PM, Igor Vaynberg wrote:


public class smallcomponent extends component {
protected imodel initmodel() {
   imodel model=super.initmodel();
   return new compoundpropertymodel(model);
}
}

-igor

On Sun, Feb 15, 2009 at 8:19 AM, Willis Blackburn  
wbo...@panix.com

wrote:


Hello,

I have a situation that keeps coming up.  All of my solutions have

seemed
clumsy, which makes me think that there's a better way of  
approaching

this
that I just haven't figured out.  Can someone point me in the  
right

direction?

What I want is to have a Page that uses CompoundPropertyModel,  
and then
include a component on that page that also uses  
CompoundPropertyModel.

So
roughly it looks like this:

public class BigObject {
public SmallObject get SmallObject() { ... }
}

public class SmallObject {
public String getName() { ... }
}

public class BigPage {
public BigPage(BigObject object) {
setModel(new CompoundPropertyModel(object));
add(new SmallComponent(smallObject));
}
}

public class SmallComponent {
public SmallComponent() {
add(new Label(name));
}
}

If I try to do just this, then I get an error because the label  
that's

part
of SmallComponent finds the BigPage model and fails because  
there's no

property of BigObject called name.

So obviously SmallComponent needs some model:

public class SmallComponent {
public SmallComponent(IModel model) {
setModel(new CompoundPropertyModel(model));
add(new Label(name));
}
}

But what model to give it?  I tried passing it new
ComponentPropertyModel(smallObject), which didn't work because
ComponentPropertyModel implements IComponentAssignedModel and thus

can't

be
directly wrapped in CompoundPropertyModel.  Adding a call to  
wrap() in

the
SmallComponent constructor fixed the problem, but I'm not sure  
if I can

just
call wrap and carry on or if there will be some unforeseen  
consequence

of

that down the road.  Is there a standard way of doing this?

Thanks,
Willis


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org





-
To unsubscribe, e-mail: users-unsubscr

Re: N-level CompoundPropertyModel

2009-02-16 Thread Willis Blackburn

Johan,

I had a similar idea, except that I used PropertyModel (which is what  
CompoundPropertyModel.bind does anyway).


The issue that I had with this one is that every component exposes a  
setModel method, so I always wonder how my components will behave if  
someone calls it.  In this case, if someone calls BigPage.setModel,  
then SmallComponent will be left pointing to the wrong model.  I try  
to have only component that holds the model object directly and let  
other components access it indirectly.


I suppose that I could do this:

add(new SmallComponent(smallObject, new PropertyModel(this,  
modelObject.smallObject)))


However, ComponentPropertyModel does the same thing in a clearer and  
slightly more efficient manner.


W


On Feb 16, 2009, at 3:04 PM, Johan Compagner wrote:


do it then a bit different

public class BigPage {
public BigPage(BigObject object) {
 CompoundPropertyModel model = new CompoundPropertyModel(object)
  setModel(model)
  add(new SmallComponent(smallObject,  
model.bind(smallObject.name));

  }
 }

public class SmallComponent {
   public SmallComponent(IModel model) {
   add(new Label(name, model);
   }
}

or

public class BigPage {
public BigPage(BigObject object) {
 CompoundPropertyModel model = new CompoundPropertyModel(object)
  setModel(model)
  add(new SmallComponent(smallObject, model.bind(smallObject));
  }
 }

public class SmallComponent {
   public SmallComponent(IModel model) {
   setModel(new CompoundPropertyModel(model));
   add(new Label(name);
   }
}



On Mon, Feb 16, 2009 at 20:59, Willis Blackburn wbo...@panix.com  
wrote:



Johan,

The below solution requires that SmallComponent know it's parent has
CompoundPropertyModel and that there is a member called  
smallObject.  I'm
trying to keep SmallComponent generic, like the Wicket built-in  
components.


W



On Feb 16, 2009, at 2:46 PM, Johan Compagner wrote:

yes initmodel shouldnt call getModel() on the parent
because that was a big performance penalty on some solutions  
because that

would create and walk over the complete hierarchy of things
and then many many in between models are created, that dont do  
really

anything.

But why not something like this:

public class BigPage {
public BigPage(BigObject object) {
setModel(new CompoundPropertyModel(object));
add(new SmallComponent(smallObject, getModel()));
}
}

public class SmallComponent {
public SmallComponent(CompoundPropertyModel model) {
add(new Label(name, model.bind(smallObject.name));
}
}

johan


On Mon, Feb 16, 2009 at 05:50, Igor Vaynberg  
igor.vaynb...@gmail.com

wrote:


hrm, looks like johan changed it here


526472  4/7/07 12:13 PM 3   jcompagner  component  
initModel will

not call
getModel on the parent, but will directly use the field (so that  
not
all kinds of inbetween models are created) if model is an  
iwrapmodel

and the wrapped modes is an inherited one then the model will be
cleared on detach Compound.getTarget() removed. Compound will not
unwrap in getObject() anymore AbstractPropertyModel will unwrap  
until

all models are processed

seems to me that the change breaks what i thought the contract of
initmodel was... we should discuss on dev, mind sending a message?

-igor


On Sun, Feb 15, 2009 at 10:08 AM, Willis Blackburn wbo...@panix.com 


wrote:


Igor,

Are you sure that will work?  I don't think that SmallComponent's


initModel


method is ever called, because when the Label that is part of


SmallComponent


is searching for a model (in Component.initModel), it invokes the
getModelImpl method of SmallComponent, which doesn't call  
initModel.



(The

comment in the code says Don't call getModel() that could  
initialize



many


in-between useless models.

W

On Feb 15, 2009, at 12:23 PM, Igor Vaynberg wrote:

public class smallcomponent extends component {

protected imodel initmodel() {
 imodel model=super.initmodel();
 return new compoundpropertymodel(model);
}
}

-igor

On Sun, Feb 15, 2009 at 8:19 AM, Willis Blackburn wbo...@panix.com 


wrote:



Hello,

I have a situation that keeps coming up.  All of my solutions  
have



seemed


clumsy, which makes me think that there's a better way of  
approaching

this
that I just haven't figured out.  Can someone point me in the  
right

direction?

What I want is to have a Page that uses CompoundPropertyModel,  
and

then
include a component on that page that also uses  
CompoundPropertyModel.

So
roughly it looks like this:

public class BigObject {
public SmallObject get SmallObject() { ... }
}

public class SmallObject {
public String getName() { ... }
}

public class BigPage {
public BigPage(BigObject object) {
  setModel(new CompoundPropertyModel(object));
  add(new SmallComponent(smallObject));
}
}

public class SmallComponent {
public SmallComponent() {
  add(new Label(name));
}
}

If I try to do just this, then I get an error because the  
label that's

part
of SmallComponent finds the BigPage model and fails because  
there's

N-level CompoundPropertyModel

2009-02-15 Thread Willis Blackburn

Hello,

I have a situation that keeps coming up.  All of my solutions have  
seemed clumsy, which makes me think that there's a better way of  
approaching this that I just haven't figured out.  Can someone point  
me in the right direction?


What I want is to have a Page that uses CompoundPropertyModel, and  
then include a component on that page that also uses  
CompoundPropertyModel.  So roughly it looks like this:


public class BigObject {
public SmallObject get SmallObject() { ... }
}

public class SmallObject {
public String getName() { ... }
}

public class BigPage {
public BigPage(BigObject object) {
setModel(new CompoundPropertyModel(object));
add(new SmallComponent(smallObject));
}
}

public class SmallComponent {
public SmallComponent() {
add(new Label(name));
}
}

If I try to do just this, then I get an error because the label that's  
part of SmallComponent finds the BigPage model and fails because  
there's no property of BigObject called name.


So obviously SmallComponent needs some model:

public class SmallComponent {
public SmallComponent(IModel model) {
setModel(new CompoundPropertyModel(model));
add(new Label(name));
}
}

But what model to give it?  I tried passing it new  
ComponentPropertyModel(smallObject), which didn't work because  
ComponentPropertyModel implements IComponentAssignedModel and thus  
can't be directly wrapped in CompoundPropertyModel.  Adding a call to  
wrap() in the SmallComponent constructor fixed the problem, but I'm  
not sure if I can just call wrap and carry on or if there will be some  
unforeseen consequence of that down the road.  Is there a standard way  
of doing this?


Thanks,
Willis


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: N-level CompoundPropertyModel

2009-02-15 Thread Willis Blackburn

Thanks for your reply.

I could do that, but then SmallComponent would effectively depend on  
BigObject.  The idea is that SmallComponent should work regardless of  
where its model object actually lives.  It could be a standalone  
object, or part of another object such as BigObject.


W


On Feb 15, 2009, at 12:00 PM, jcgarciam wrote:



Hi,

Have you tried using an expression as the name of your Label  
component which

match your object model hierarchy.

i.e:

add(new Label(smallObject.name));





Willis Blackburn wrote:


Hello,

I have a situation that keeps coming up.  All of my solutions have
seemed clumsy, which makes me think that there's a better way of
approaching this that I just haven't figured out.  Can someone point
me in the right direction?

What I want is to have a Page that uses CompoundPropertyModel, and
then include a component on that page that also uses
CompoundPropertyModel.  So roughly it looks like this:

public class BigObject {
public SmallObject get SmallObject() { ... }
}

public class SmallObject {
public String getName() { ... }
}

public class BigPage {
public BigPage(BigObject object) {
setModel(new CompoundPropertyModel(object));
add(new SmallComponent(smallObject));
}
}

public class SmallComponent {
public SmallComponent() {
add(new Label(name));
}
}

If I try to do just this, then I get an error because the label  
that's

part of SmallComponent finds the BigPage model and fails because
there's no property of BigObject called name.

So obviously SmallComponent needs some model:

public class SmallComponent {
public SmallComponent(IModel model) {
setModel(new CompoundPropertyModel(model));
add(new Label(name));
}
}

But what model to give it?  I tried passing it new
ComponentPropertyModel(smallObject), which didn't work because
ComponentPropertyModel implements IComponentAssignedModel and thus
can't be directly wrapped in CompoundPropertyModel.  Adding a call to
wrap() in the SmallComponent constructor fixed the problem, but I'm
not sure if I can just call wrap and carry on or if there will be  
some
unforeseen consequence of that down the road.  Is there a standard  
way

of doing this?

Thanks,
Willis


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org





--
View this message in context: 
http://www.nabble.com/N-level-CompoundPropertyModel-tp22024267p22024775.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: N-level CompoundPropertyModel

2009-02-15 Thread Willis Blackburn

Igor,

Are you sure that will work?  I don't think that SmallComponent's  
initModel method is ever called, because when the Label that is part  
of SmallComponent is searching for a model (in Component.initModel),  
it invokes the getModelImpl method of SmallComponent, which doesn't  
call initModel.  (The comment in the code says Don't call getModel()  
that could initialize many in-between useless models.


W

On Feb 15, 2009, at 12:23 PM, Igor Vaynberg wrote:


public class smallcomponent extends component {
 protected imodel initmodel() {
 imodel model=super.initmodel();
 return new compoundpropertymodel(model);
  }
}

-igor

On Sun, Feb 15, 2009 at 8:19 AM, Willis Blackburn wbo...@panix.com  
wrote:

Hello,

I have a situation that keeps coming up.  All of my solutions have  
seemed
clumsy, which makes me think that there's a better way of  
approaching this

that I just haven't figured out.  Can someone point me in the right
direction?

What I want is to have a Page that uses CompoundPropertyModel, and  
then
include a component on that page that also uses  
CompoundPropertyModel.  So

roughly it looks like this:

public class BigObject {
  public SmallObject get SmallObject() { ... }
}

public class SmallObject {
  public String getName() { ... }
}

public class BigPage {
  public BigPage(BigObject object) {
  setModel(new CompoundPropertyModel(object));
  add(new SmallComponent(smallObject));
  }
}

public class SmallComponent {
  public SmallComponent() {
  add(new Label(name));
  }
}

If I try to do just this, then I get an error because the label  
that's part
of SmallComponent finds the BigPage model and fails because there's  
no

property of BigObject called name.

So obviously SmallComponent needs some model:

public class SmallComponent {
  public SmallComponent(IModel model) {
  setModel(new CompoundPropertyModel(model));
  add(new Label(name));
  }
}

But what model to give it?  I tried passing it new
ComponentPropertyModel(smallObject), which didn't work because
ComponentPropertyModel implements IComponentAssignedModel and thus  
can't be
directly wrapped in CompoundPropertyModel.  Adding a call to wrap()  
in the
SmallComponent constructor fixed the problem, but I'm not sure if I  
can just
call wrap and carry on or if there will be some unforeseen  
consequence of

that down the road.  Is there a standard way of doing this?

Thanks,
Willis


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Hi

2009-02-15 Thread Willis Blackburn

Swapna,

You can set up the radio buttons to submit the form via ajax when the  
user clicks on.  See AjaxFormSubmitBehavior.


W


On Feb 15, 2009, at 8:13 PM, Swapna Rachamalla wrote:


Hi

Using Apache Wicket:

I have a form.In that form i have Radio button group like:

Country

  - USA
  - UK

I dont have any submit buttons for the form. I have added Only  
RadioButton

Group.

But i want to write some logic based on selection of Radio button  
selection.


do we have any method to override like onSubmit() for form if the  
the form

has a Submit button

Thanks
Swapna



-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org