LazyInit error with LDM in a panel

2008-10-29 Thread Neil McT

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: LazyInit error with LDM in a panel

2008-10-29 Thread Neil McT

Its probably not fool-proof, but it has worked fine up till now



public class MyLDMT extends MyDomainModelIF extends
LoadableDetachableModel{

private MyServiceIFT modelLoaderService;
private Long id;

/**
 * Constructor.
 *
 * @param object the model to make 'detachable'
 * @param modelLoaderService used to load the model
 */
public MyLDM(T object, MyServiceIFT 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]



Re: DHTML DnD best practice?

2008-10-17 Thread Neil McT

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?

2008-10-17 Thread Neil McT

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]



DHTML DnD best practice?

2008-10-16 Thread Neil McT

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: DHTML DnD best practice?

2008-10-16 Thread Neil McT

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]



Re: DHTML DnD best practice?

2008-10-16 Thread Neil McT

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]



Loadable-detachable collections?

2008-09-26 Thread Neil McT

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: Loadable-detachable collections?

2008-09-26 Thread Neil McT

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]



Re: Loadable-detachable collections?

2008-09-26 Thread Neil McT

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?

2008-09-26 Thread Neil McT

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?

2008-09-26 Thread Neil McT

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]



Turning off SWARM for testing?

2008-09-18 Thread Neil McT

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]



Re: Turning off SWARM for testing?

2008-09-18 Thread Neil McT

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]



RE: Turning off SWARM for testing?

2008-09-18 Thread Neil McT


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?

2008-09-18 Thread Neil McT


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]



Problem sharing model between 2 panels

2008-09-05 Thread Neil McT

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

2008-08-28 Thread Neil McT

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

2008-08-12 Thread Neil McT


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]



Re: Markup inheritance for secure and non-secure pages

2008-08-12 Thread Neil McT

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]