Re: LazyInit error with LDM in a panel
Its probably not fool-proof, but it has worked fine up till now public class MyLDM extends LoadableDetachableModel{ private MyServiceIF modelLoaderService; private Long id; /** * Constructor. * * @param object the model to make 'detachable' * @param modelLoaderService used to load the model */ public MyLDM(T object, MyServiceIF modelLoaderService){ super(object); this.modelLoaderService = modelLoaderService; this.id = object.getId(); } public MyLDM(Long id){ super(); this.id = id; } @Override protected T load() { return modelLoaderService.load(id); } public void setId(Long id) { this.id = id; } @Override @SuppressWarnings("unchecked") public T getObject(){ return (T)super.getObject(); } } igor.vaynberg wrote: > > what is your ldm implementation look like? > > and yes, delayed construction is always the way to go. > > -igor > > On Wed, Oct 29, 2008 at 7:44 AM, Neil McT <[EMAIL PROTECTED]> > wrote: > > > > -- View this message in context: http://www.nabble.com/LazyInit-error-with-LDM-in-a-panel-tp20228580p20231137.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
LazyInit error with LDM in a panel
Hi, I've got the above problem which I have boiled down to the following basic example. MyPage references PanelA and PanelB which it swaps about depending on the current state - both are created when the page is created but PanelA is added to MyPage as the default display panel. PanelB contains the following label... add(new Label("testLabel", new PropertyModel(myLDM, "someCollection"))); myLDM is a LoadableDetachableModel which wraps a hibernate entity which, in turn, has a 'someCollection' property. On loading MyPage (first request), everything is fine (MyPage creates PanelA and PanelB and displays PanelA). However on moving to PanelB (second request) I get a LazyInitializationException saying that someCollection couldn't be loaded. I've already found a fix to this problem I delay the creation of the panels until they are actually being used (i.e. on the call to Panel.replaceWith()). However, I just can't really get my head around why this fails in the first place. Basically why is the LDM not calling load() on the second request? Also, as the late-construction of the panels seems to work... is this what people would recommend when swapping panels in and out of a page? Any help much appreciated, Neil. -- View this message in context: http://www.nabble.com/LazyInit-error-with-LDM-in-a-panel-tp20228580p20228580.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Adding Ajax behavior changes component id
Yeah, I understand why this would be the case in say a ListView (when repeated markup would not have a unique id) but when adding a behavior to a component 'myId3' is no more unique than 'myId'. Under what circumstances would the original id no longer be unique? I think that is what I am asking. Thanks for your reply. Nino.Martinez wrote: > > Hi Neil > > It's id because it's the only thing unique.. > > Neil McT wrote: >> Hi, >> >> I noticed that when I add an Ajax behavior to a component, that >> components >> id is changed - from 'myId' to say 'myId3'. >> >> I know there are ways around this e.g. use the css class to identify the >> component rather than the id - but I am wondering why this is? >> >> Thanks, >> >> Neil. >> > > -- > -Wicket for love > > Nino Martinez Wael > Java Specialist @ Jayway DK > http://www.jayway.dk > +45 2936 7684 > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- View this message in context: http://www.nabble.com/Adding-Ajax-behavior-changes-component-id-tp20046426p20049320.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Adding Ajax behavior changes component id
Hi, I noticed that when I add an Ajax behavior to a component, that components id is changed - from 'myId' to say 'myId3'. I know there are ways around this e.g. use the css class to identify the component rather than the id - but I am wondering why this is? Thanks, Neil. -- View this message in context: http://www.nabble.com/Adding-Ajax-behavior-changes-component-id-tp20046426p20046426.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: DHTML DnD best practice?
Thanks for the reply. This is just the starter-for-ten I was looking for. I also found one of the London Wicket groups presentations ( http://londonwicket.org/content/LondonWicket-ListEditor.pdf http://londonwicket.org/content/LondonWicket-ListEditor.pdf ) to be of great use. It actually became less about the immediate problem and more about a gap in my (albeit basic) understanding of Wicket. Having messed around for the last couple of hours, given some of the pointers on here, I am feeling far more comfortable with the Ajax / dhtml side of wicket. Cheers. reiern70 wrote: > > Sorry, maybe I do not fully understand what you want to do but why won't > you > update the state of the server once a div is dropped. > I have my own components that use drag and drop (e.g. tables with > draggable/dropable columns) and what I do at the JavaScript side is > something like: > XXX.onDrop() { > var url = this.url+ '&sourceId=' + parseInt(td.style.width) + > '&targetId=resize' + '&number=' + this.number > wicketAjaxGet(url); > } > ... > -- View this message in context: http://www.nabble.com/DHTML-DnD-best-practice--tp20010633p20033321.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: DHTML DnD best practice?
Ok, so I had a look at the Palette component. Its very nice, but I don't think it really helps me as it uses a select box (i.e. a pre-existing wicket component) as a 'bin' for the droppables. This really abstracts out the main part of my problem - how to bind and manipulate a bunch of divs with a custom component. To explain further: what I will end up with is a droppable 'bin' (a div) which the user has been happily dragging stuff (other divs) onto - and possibly sorting etc. The hole in my knowledge here is how to associate these inner divs (the things that have been dropped) with some Wicket component on the server side. I can associated the 'bin' div with a MarkupContainer or something but I'm not sure how to dynamically keep track of its inner divs once the user has submitted. I've tried a solution using a ListView nested within a form but I'm not entirely happy with it. For example, the number of 'slots' to drag things onto has to be known at construction time - i.e. the user can not drag on 11 things if only 10 slots (say, nested textfields) have been created at construction time (also I would prefer not to have pre-determined 'slots' - just an area onto which many divs can be dragged). I would like to use Jquery to do all the fancy front-end stuff (creating new 'slots' on the fly, sorting etc) and just bind the results (all the dragged-on divs) to some component in Wicket. I've been playing about with wicket for about a month and this question actually reflects an area of the Framework that I am not really getting so far - how markup is bound to components at the lower level. I've read many examples and the excellent Wicket in Action book but, understandably, they seem to focus on how to use existing components and only briefly touch on how to create your own components and how to really 'get at' the underlying markup. Any help, hints or pointers to further reading would be much appreciated as, my current problem aside, I feel this is an area I need to crack before I go any further. Thanks - Neil. Serkan Camurcuoglu wrote: > > it seems like you're talking about the DnD version of the Palette > component in wicket extensions.. See its source code, maybe it will give > you some idea.. > -- View this message in context: http://www.nabble.com/DHTML-DnD-best-practice--tp20010633p20029961.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: DHTML DnD best practice?
lol... fair enough. Thought it sounded too good to be true :) Serkan Camurcuoglu wrote: > > sorry for the misunderstanding, I meant to say "you're trying to build a > DnD version of the palette" (which doesn't exist yet :).. > -- View this message in context: http://www.nabble.com/DHTML-DnD-best-practice--tp20010633p20016826.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: DHTML DnD best practice?
Hmm... I can only find the non-DnD version of the palette. Any idea where the DnD version lives? Serkan Camurcuoglu wrote: > > it seems like you're talking about the DnD version of the Palette > component in wicket extensions.. See its source code, maybe it will give > you some idea.. > > > -- View this message in context: http://www.nabble.com/DHTML-DnD-best-practice--tp20010633p20016818.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
DHTML DnD best practice?
Hi, I'm wondering what would be the best way to enable dhtml drag n drop in Wicket. Its a fairly typical use-case I have 2 divs, one is a container of draggables, the other is a container of droppables - i.e. where the draggables will be dragged to. This is not an ajax question as there is no need for any server side round-trip on each drop - only some kind of submit button once the user is happy with what they have dragged on. I have the front-end component working (using jquery ui drag n drop) but my question is... what would be the recommended way to communicate the dropped objects to the server side using wicket? I.e. what would be the recommended component to bind the 'droppable' container (or individual droppable objects) to and how would you guys recommend that I reconstruct the dropped objects on the server side? I have thought of various ways I can enable this, but none of these seem particularly like the 'right' Wicket way - and kind of smack of the way I would have done things in, say, struts. Thanks in advance. -- View this message in context: http://www.nabble.com/DHTML-DnD-best-practice--tp20010633p20010633.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Loadable-detachable collections?
That worked a charm Nino, thanks. I can see now that I was previously setting a raw SystemUser object as the ListView model as opposed to the wrapped LDM object. I'll still check out the DataView as well. Thanks all for your replies. Nino.Martinez wrote: > > You are not chaining... > > This is how: > > new PropertyModel(userModel,"contacts") > > > -- View this message in context: http://www.nabble.com/Loadable-detachable-collections--tp19685949p19693433.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Loadable-detachable collections?
Sure. Originally I had it set up like (note that userModel is a LDM which wraps a SystemUser. SystemUser contains a collection of Contact objects). final WebMarkupContainer listContainer = new WebMarkupContainer("listContainer"); ListView displayList = new ListView("contactsList", userModel.getObject().getContacts()){ @Override protected void populateItem(final ListItem item) { Contact contact = (Contact)item.getModelObject(); item.add(new Label("contactName", contact.getName())); etc etc This was producing the original error AbstractPersistentCollection.owner [class=com.myapp.domain.SystemUser] <- field that is not serializable I then tried. final WebMarkupContainer listContainer = new WebMarkupContainer("listContainer"); ListView displayList = new ListView( "contactsList", new PropertyModel(userModel.getObject(), "contacts")){ @Override protected void populateItem(final ListItem item) { item.add(new Label("contactName", ((Contact)item.getModelObject()).getName())); etc etc And was getting private java.lang.Object org.apache.wicket.model.AbstractPropertyModel.target [class=com.pyso.domain.SystemUser] <- field that is not serializable I'm assuming, from the PropertyModel. jwcarman wrote: > > How about sharing some code with us as to how you're setting up your > models? > > -- View this message in context: http://www.nabble.com/Loadable-detachable-collections--tp19685949p19693132.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Loadable-detachable collections?
I wasn't getting the error from the main LDM but from the underlying collection (and its reference back to 'owner'). I need to display all collections elements in this instance but maybe on other pages, only a subset. Thanks both for your replies. I'm probably going to have a look at DataView. jwcarman wrote: > > Yes, perhaps I wasn't clear enough. But, Martijn is correct. A > DataView (which uses a DataProvider) might be a better choice in your > situation (unless you have to load the entity to display other parts > of your page anyway). Are you always showing all members of the > nested collection? > > -- View this message in context: http://www.nabble.com/Loadable-detachable-collections--tp19685949p19692314.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Loadable-detachable collections?
Yeah, I originally had that - a LDM as the main model and the ListView model based on that. I've also tried a couple of variations of this but I still get the Serialization errors. I think maybe I'm not following you exactly. As far as I can see the ListView needs a collection as a model (the collection of Contacts) and, no matter how I configure this model, it will still point to non-serializable objects (either the 'owner' property of the AbstractPersistentCollection or perhaps the Contacts themselves). So does the collection itself need to be Loadable / Detachable? Thanks. jwcarman wrote: > > I usually use a LDM for the main object (which has the collection > property) and have the model for the collection based upon that > (perhaps a PropertyModel?). > > -- View this message in context: http://www.nabble.com/Loadable-detachable-collections--tp19685949p19691650.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Loadable-detachable collections?
I'm using LoadableDetachableModels to minimise the serialized session state of my app. However, there is one place where I am still seeing WicketNotSerializableException and that is where I use a hibernate collection as a components model. I have a SystemUser class which contains a List of Contact objects - both are hibernate entities. This collection of Contact objects form the model for a ListView but throws the WicketNotSerializableException as follows... [snip] private java.lang.Object org.hibernate.collection.AbstractPersistentCollection.owner [class=com.myapp.domain.SystemUser] <- field that is not serializable So it seems that the underlying hibernate collection has a field 'owner' (in this case the SystemUser) which wicket is trying to serialize. I'm not sure of the best way to make this owner object (and the collection objects themselves, probably) LoadableDetachableObjects. Any ideas? Thanks - Neil. -- View this message in context: http://www.nabble.com/Loadable-detachable-collections--tp19685949p19685949.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Turning off SWARM for testing?
Sorry - fairly new to Wicket - don't quite follow. Do you mean subclass AuthenticatedWebSession in the test environment to always return true on authenticate() ? How would this play with SWARM? I have just found an, albeit more convoluted, solution My TestApplication class overrides setupStrategyFactory to return a dummy strategy factory which is configured with a stub implementation of ISecureComponent. Digging about in the SWARM code it seems that only subclasses of this stub will be authenticated - and as there are no subclasses, authentication has been essentially circumvented. Not the prettiest solution but it _seems_ to work. Martijn Dashorst wrote: > > Why not create an authenticated session instead? > > Martijn > > > -- View this message in context: http://www.nabble.com/Turning-off-SWARM-for-testing--tp19557765p19560295.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Turning off SWARM for testing?
I tried that but it didn't work. But it did remove the need for me to manufacture a unique hive-key per WicketTester instance... so it wasn't a total loss :) Hoover, William wrote: > > Try HiveMind.unregisterHive(hiveKey); > > > -- View this message in context: http://www.nabble.com/Turning-off-SWARM-for-testing--tp19557765p19558799.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Turning off SWARM for testing?
Sorry not sure what you mean by 'swarm auth strategy' My application class extends SwarmWebApplication and the only SWARM specific methods it overrides are getHiveKey() and setUpHive() - where I add the policy file. Is it one of these that I should be 'nulling out' for testing? Thanks. igor.vaynberg wrote: > > have an overrideable method on your application boolean > issecurityenabled(), and only add swarm auth strategy if it returns > true. that way during tests you can give tester a subclass of your app > that returns false. > > -igor > > -- View this message in context: http://www.nabble.com/Turning-off-SWARM-for-testing--tp19557765p19558153.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Turning off SWARM for testing?
Is there any way to turn-off / circumvent SWARM for testing? I'm using WicketTester and any time I attempt to navigate to a protected page (i.e. implements ISecurePage) I get bounced back to my login-page. I'd prefer not to have to go to the lengths of 'logging in' a user, just for tests as I'd prefer my unit tests to be as focussed as possible. Any help much appreciated. Neil. -- View this message in context: http://www.nabble.com/Turning-off-SWARM-for-testing--tp19557765p19557765.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Problem sharing model between 2 panels
Here is the problem I have a Parent panel which swaps in and out a Display panel and an Update panel (these are basically 2 views, read-only and read-write, of a users details). To enable any changes by the Update panel to be seen by the Display panel, I have both panels pointing to the same model, which in turn wraps the same user object. However, the Update panel uses a form to affect changes. This form also points to the same Model / Object and herein lies the problem the form maintains the same model throughout requests (as expected) BUT after debugging I found that it seems to be creating a different underlying model-object for each request. Therefore, while both my panels point to the same Model / Object the form is making changes to a different Object! Long story short after swapping the panels post-Update the changes are not seen by the Display panel. Is this form behaviour what you would expect to see? If so, is there a more elegant solution than just manually copying the changed fields between model-objects or grabbing the changed user object from the db again? Any help, very much appreciated. Thanks - Neil. -- View this message in context: http://www.nabble.com/Problem-sharing-model-between-2-panels-tp19330828p19330828.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Reading Wicket properties file WITH substitutions
Hi there, I'm looking for suggestions as how best to read a Wicket .properties file AND include the text substitutions. Specifically I've overriden certain validation error messages in a properties file e.g StringValidator.range=${label} must be between ${minimum} and ${maximum} characters long As expected, this works fine from the front end. However, when I try to access the value FROM A TEST using... props = (PropertyResourceBundle)ResourceBundle.getBundle("my.props.file.here"); props.getString(key); I get the literal string i.e. with the ${xxx} entries instead of the actual values. I understand that this is also as expected as its just grabbing the property. However I'm wondering how best to invoke the wicket pre-processing? Thanks, Neil. -- View this message in context: http://www.nabble.com/Reading-Wicket-properties-file-WITH-substitutions-tp19205222p19205222.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Markup inheritance for secure and non-secure pages
Ahh... I was digging about and found this nugget http://www.nabble.com/wicket-security%2C-everybodyprincipal-and-only-securepages-td15413102.html#a15419077 here "..since you probably want every page to extend BasePage why not have a subclass that implements ISecurePage and have all your pages that should be secure extend that page. For the implementation of ISecurePage you can simply redirect all calls to the SecureComponentHelper." Looks like SecureComponentHelper is the answer to my problems. Thanks for your help. Neil McT wrote: > > > So, in terms of WASP / SWARM... what is it that makes SecureBasePage > secure? I.e. it doesn't extend SecureWebPage. I'm assuming, therefore, > that it implements ISecurePage? > > .. > > -- View this message in context: http://www.nabble.com/Markup-inheritance-for-secure-and-non-secure-pages-tp18952852p18953560.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Markup inheritance for secure and non-secure pages
So, in terms of WASP / SWARM... what is it that makes SecureBasePage secure? I.e. it doesn't extend SecureWebPage. I'm assuming, therefore, that it implements ISecurePage? Thanks - Neil. Martijn Dashorst wrote: > > AbstractBasePage extends WebPage > > SecureBasePage extends AbstractBasePage > > This is how we do it in our projects. > > Martijn > > > > -- View this message in context: http://www.nabble.com/Markup-inheritance-for-secure-and-non-secure-pages-tp18952852p18953397.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Markup inheritance for secure and non-secure pages
Hi folks, I'm new to Wicket so please forgive me if I ask something incredibly dumb :) I've just started using Wicket and am enjoying it very much. I'm putting together an application using SWARM / WASP for my authentication / authorisation and would like to use markup inheritance to give a consistent look and feel for both secure AND non-secure pages.. and this is where I've run into my first problem. I would like all off my pages to extend some base-page however my secure pages all extend SecureWebPage. So basically my secure and non-secure web pages cannot extend the same base page. As far as I can see my options are 1) Rather than extend SecureWebPage my secure pages can implement ISecurePage, however this would require quite a few additional methods to be implemented (and duplicated) across my secure pages. 2) Rather than go for a page-based layout I could go for a single page with a panel-based layout and manage security on a panel-by-panel basis. However, I prefer the navigation aspect of the page-based layout and I prefer to assign permissions in SWARM on a page-by-page basis (and find it easier / more intuitive to authenticate on a page-basis). Am I missing something simple here? Does anyone have any other suggestions? Any help much appreciated, Neil. -- View this message in context: http://www.nabble.com/Markup-inheritance-for-secure-and-non-secure-pages-tp18952852p18952852.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]