Re: Refreshing a List view

2008-06-05 Thread Sam Barnum

Ricky, what are you using as the model for your refreshing view?

You should be using some sort of detachable model that re-fetches the  
items for the list from the DB each time.


--
Sam Barnum
360 Works
http://www.360works.com
415.865.0952



On Jun 5, 2008, at 10:32 AM, Ricky wrote:


Hi,

I have a RefreshingView which has a delete button in it (this  
deletes the
model present in the backing list for the view.) The problem is  
that when a

delete is performed on DB, (see onSubmit( ) for
*deletePlanObjectiveDetailButton
below)  *the size of the list changes, Is there a way to refresh  
the view

after I remove the model from the backing list (list.remove( xxx )) ??
Here's a snippet of what i am doing:

*new RefreshingView(refreshing-view-list) {

// populate item.
protected final void populateItem(final Item item) {
final MODEL backingListModel = (backingListModel)
item.getModelObject();

 item.add(new Label(label-objective-name,
backingListModel.getName()));

final Button deletePlanObjectiveDetailButton = new
Button(button-delete-plan-objective-details) {
private static final long serialVersionUID = 1L;

// onSubmit.
public final void onSubmit() {
new
ObjectiveMeasureDataProvider().deleteObjectiveMeasure 
(backingListModel);
backingListModels.remove(  );  ///   
Searches

for backing Model deleted in current list based on id and removes it.
// TODO Figure out a way to do list view  
refresh

here.
  }
};
  item.add(deletePlanObjectiveDetailButton);
}
};

*Any Help would be appreciable!!???*
*Rick




Ajax works in DEVELOPMENT, not in DEPLOYMENT

2008-05-29 Thread Sam Barnum
I'm using an AjaxFormChoiceComponentUpdatingBehavior on a RadioGroup  
to show/hide a component elsewhere on the page.


This works great in development mode.  When I push it up to the  
server, I get nothing, clicking on the various radio buttons doesn't  
do anything.  And unfortunately, the handy wicket ajax debugger isn't  
there in deployment mode.


I've looked at the javascript code, and aside from the markup IDs  
being different, everything looks all right.  No javascript errors in  
FireFox.


I've tried tracing through it in Firebug, but it gets really  
convoluted.  A lot of ajax stuff, doPost() etc. happens.  It's hard  
to get a break point in the callback though.


What are the possible reasons this might work in development but not  
in deployment?


How can I debug code that's on the server? Is there any way to get  
the ajax feedback panel to come up on the server?


-Sam

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Ajax works in DEVELOPMENT, not in DEPLOYMENT

2008-05-29 Thread Sam Barnum

Thanks as always, Igor




getDebugSettings().setAjaxDebugModeEnabled(true);

-igor




-Sam

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: RequiredBorder being applied multiple times in ajax calls

2008-05-16 Thread Sam Barnum
Awesome, that works!  I forgot that you can always get the request  
from that ThreadLocal.  Thanks a ton Gerolf, this doesn't seem too  
hacky.


--
Sam Barnum
360 Works

On May 15, 2008, at 10:58 AM, Gerolf Seitz wrote:


On Thu, May 15, 2008 at 6:25 PM, Sam Barnum [EMAIL PROTECTED] wrote:


* Somehow disable the border only for ajax calls



Sam,
I think you can do something like this in RequiredBorder#renderAfter:

AjaxRequestTarget target = AjaxRequestTarget.get();
if (target == null) {
  // we're in a normal request
  // put logic of the original renderAfter here
}

not sure if that works, but you might wanna give that a try.

cheers,
  Gerolf



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: RequiredBorder being applied multiple times in ajax calls

2008-05-15 Thread Sam Barnum

Gerolf,

Thanks for the reply.  WicketAjaxIndicatorAppender is a behavior, but  
my RequiredBorder is a border.  It seems like there's got to be an  
easy answer to this that doesn't require a javascript hack.


Here's what I think is happening:

* The phone format is rendered on the first pass, and the  
RequiredBorder draws an asterisk after the field.
* The AjaxFormComponentUpdatingBehavior fires, to format the phone  
number.  The phone input (TextField) is added to the ajax request target
* The ajaxReqestTarget replaces the components of the phone input.   
However, the HTML generated by the border is not replaced.  The phone  
input border draws around the phone input, and you end up with two  
nested borders around the phone input.  Repeating the process nests  
the borders further.


Possible solutions:
* Remove / disable the border after it renders the first time.  This  
solves the ajax issue, but when the entire page is redrawn, the  
borders all disappear
* Somehow tell the ajaxRequestTarget to replace the input along with  
its component border, not just the input.  Not sure how to do this.

* Somehow disable the border only for ajax calls
* Don't use the border, manually add a required indicator next to  
every required field in my application. Not looking forward to this  
one...


Option #2 sounds the most promising, but I don't know where to begin.

-Sam

On May 14, 2008, at 11:38 PM, Gerolf Seitz wrote:


Sam,
a similar issue happened to the WicketAjaxIndicatorAppender.
take a look at WicketAjaxIndicatorAppender#renderHead to see
how this is solved there.
maybe you can do something similar with your RequiredBorder.

regards,
  Gerolf

On Thu, May 15, 2008 at 2:58 AM, Sam Barnum [EMAIL PROTECTED] wrote:


Using the tips in this PDF
http://londonwicket.org/content/LondonWicket-FormsWithFlair.pdf

I created the simple RequiredBorder class as follows:

public class RequiredBorder extends MarkupComponentBorder {
   public void renderAfter(Component component) {
   FormComponent fc = (FormComponent) component;
   if (fc.isRequired()) {
   super.renderAfter(component);
   }
   }
}

This basically adds a * after any required fields.  It seemed to  
work

great until I used it with an ajax phone formatter behavior:

new AjaxFormComponentUpdatingBehavior(onchange) {
   protected void onUpdate(AjaxRequestTarget target) {
   Object oldValue = component.getValue();
   String formatted = new PhoneFormatter().format 
(oldValue);

   component.setModelObject(formatted);
   target.addComponent(component);
   }
}


This caused duplicate * indicators to appear after my phone  
field when

the phone number changed, one per onchange request.  I tried adding a
boolean field to the RequiredBorder so it only gets processed  
once.  This
fixed the phone formatter duplicates, but if the form submits and  
stays on

the same page, all the * marks disappear from the required fields.

This is definitely some sort of lifecycle problem, but how do you  
fix it?


On a related note, is it generally a bad idea to mix AJAX and non- 
ajax
actions?  It seems like this is one of many issues I've run into  
when doing

this.

Thanks,

-Sam Barnum



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: RequiredBorder being applied multiple times in ajax calls

2008-05-15 Thread Sam Barnum
Matthew, we wrote the phone formatter in house.  It's way too messy  
to share on here.  If I were going to rewrite it, I'd use regex to:


* Strip everything except [0-9x#] from the input
* Everthing before the 'x' or '#' is the phone number, everything  
after is the extension
* Count the number of digits in the phone number part.  Make sure  
there are 10, then format it as (###) ###- ext. ###


--
Sam Barnum
360 Works
http://www.360works.com
415.865.0952



On May 14, 2008, at 11:06 PM, Matthew Young wrote:

Sorry I can't help you with your question.  But may I ask where you  
get the

PhoneFormatter?

On Wed, May 14, 2008 at 5:58 PM, Sam Barnum [EMAIL PROTECTED] wrote:


Using the tips in this PDF
http://londonwicket.org/content/LondonWicket-FormsWithFlair.pdf

I created the simple RequiredBorder class as follows:

public class RequiredBorder extends MarkupComponentBorder {
   public void renderAfter(Component component) {
   FormComponent fc = (FormComponent) component;
   if (fc.isRequired()) {
   super.renderAfter(component);
   }
   }
}

This basically adds a * after any required fields.  It seemed to  
work

great until I used it with an ajax phone formatter behavior:

new AjaxFormComponentUpdatingBehavior(onchange) {
   protected void onUpdate(AjaxRequestTarget target) {
   Object oldValue = component.getValue();
   String formatted = new PhoneFormatter().format 
(oldValue);

   component.setModelObject(formatted);
   target.addComponent(component);
   }
}


This caused duplicate * indicators to appear after my phone  
field when

the phone number changed, one per onchange request.  I tried adding a
boolean field to the RequiredBorder so it only gets processed  
once.  This
fixed the phone formatter duplicates, but if the form submits and  
stays on

the same page, all the * marks disappear from the required fields.

This is definitely some sort of lifecycle problem, but how do you  
fix it?


On a related note, is it generally a bad idea to mix AJAX and non- 
ajax
actions?  It seems like this is one of many issues I've run into  
when doing

this.

Thanks,

-Sam Barnum




RequiredBorder being applied multiple times in ajax calls

2008-05-14 Thread Sam Barnum

Using the tips in this PDF
http://londonwicket.org/content/LondonWicket-FormsWithFlair.pdf

I created the simple RequiredBorder class as follows:

public class RequiredBorder extends MarkupComponentBorder {
public void renderAfter(Component component) {
FormComponent fc = (FormComponent) component;
if (fc.isRequired()) {
super.renderAfter(component);
}
}
}

This basically adds a * after any required fields.  It seemed to  
work great until I used it with an ajax phone formatter behavior:


new AjaxFormComponentUpdatingBehavior(onchange) {
protected void onUpdate(AjaxRequestTarget target) {
Object oldValue = component.getValue();
String formatted = new PhoneFormatter().format(oldValue);
component.setModelObject(formatted);
target.addComponent(component);
}
}


This caused duplicate * indicators to appear after my phone field  
when the phone number changed, one per onchange request.  I tried  
adding a boolean field to the RequiredBorder so it only gets  
processed once.  This fixed the phone formatter duplicates, but if  
the form submits and stays on the same page, all the * marks  
disappear from the required fields.


This is definitely some sort of lifecycle problem, but how do you fix  
it?


On a related note, is it generally a bad idea to mix AJAX and non- 
ajax actions?  It seems like this is one of many issues I've run into  
when doing this.


Thanks,

-Sam Barnum

Re: How do I elegantly put feedback per form field?

2008-03-21 Thread Sam Barnum
+1 on the london wicket slides, an excellent (and quick) read. Would  
love to see more example like this.  Guice?


-Sam

On Mar 20, 2008, at 8:46 AM, James Carman wrote:


On 3/20/08, Ned Collyer [EMAIL PROTECTED] wrote:


 Thanks Craig,

 Perfect.

 Super perfect :)



Yeah, that's really cool!  I think I might borrow your ideas on our
project at work.  Thanks!

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Binding component visibility attribute to another form value

2008-02-26 Thread Sam Barnum

Thanks Timo,

It didn't occur to me to override isVisible, I assumed I had to call  
setVisible(). I still have it ingrained into my head that subclassing  
is something that should be avoided.  So obviously I run into these  
issues when using Wicket, where subclassing existing components is  
essential.


-Sam

On Feb 25, 2008, at 7:35 PM, Timo Rantalaiho wrote:


On Mon, 25 Feb 2008, Sam Barnum wrote:

It seems like writing a custom behavior is the right way to do this,
but once I call setVisible(false) on a component the beforeRender()
method in my behavior doesn't get called anymore, and the component
never becomes visible.

...

DropDownChoice report = new DropDownChoice(report ; new
PropertyModel(this, selectedReport), reportOptions );

WebMarkdupContainer f1 = new WebMarkupContainer(f1);
f1.add(new AbstractBehavior() {
public void onComponentTag(Component component, ComponentTag tag) {
// only show the component if it's enabled for the selected
report
component.setVisible(selectedReport != null 
selectedReport.isField1Enabled());
super.onComponentTag(component, tag);
}
} );


class ReportDependentWebMarkupContainer extends  
WebMarkupContainer {

public ReportDependentWebMarkupContainer(String id) {
super(id);
}

@Override public boolean isVisible() {
if (selectedReport == null) {
return false;
}
return selectedReport.isField1Enabled());
}
}

WebMarkupContainer f1 = new ReportDependentWebMarkupContainer 
(f1);



If you don't want to override isVisible(), you can do
setting the visiblity in Component.onBeforeRender().

I'm not sure if you can control visibility in a Behavior,
but have a vague memory that we tried it sometime and
couldn't do it either.


Should I always keep the component visible and have my behavior
replace all the contents after rendering?


No.

Best wishes,
Timo

--
Timo Rantalaiho
Reaktor Innovations OyURL: http://www.ri.fi/ 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Swing application and Wicket

2008-02-26 Thread Sam Barnum
Wicket doesn't really include a web services component that I know  
of, but you can run web services in the same application server using  
xfire, xerces, or jaxws


-Sam

On Feb 26, 2008, at 5:46 AM, Martin Makundi wrote:


Why you need wicket for?

2008/2/26, Klearhos Klearhou [EMAIL PROTECTED]:

Hello,

 the reason lies into a projects specifics needs. I need to have  
access to local resources of the system.
 I will deploy my app with java web start and it communicate with  
web services.


 Is there any way to call web services from inside the wicket  
framework ??


 Thank you again


 - Original Message 
 From: Martin Makundi [EMAIL PROTECTED]
 To: users@wicket.apache.org
 Sent: Tuesday, 26 February, 2008 3:28:11 PM
 Subject: Re: Swing application and Wicket

 Why you need both wicket and swing?

 2008/2/26, Klearhos Klearhou [EMAIL PROTECTED]:

Hello,

 I want to have an external application (swing for example) that  
will update a DB.
 I want wicket to be the front end and basically present the  
informations form the DB.


 I am thinking the communication between the swing application  
and the server to take place with a web service.

 Do you find any problems with this model?

 Thank you in advance






  __
 Sent from Yahoo! Mail.
 A Smarter Inbox. http://uk.docs.yahoo.com/nowyoucan.html

  
 
-

 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




  
-

 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]






  __
 Sent from Yahoo! Mail.
 A Smarter Inbox. http://uk.docs.yahoo.com/nowyoucan.html

  
-

 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: CompoundModel based on proxies

2008-02-26 Thread Sam Barnum
IntelliJ does a good job of locating String usages of property names  
when you refactor a property name, which is nice.  Not sure if  
Eclipse/Netbeans do this also.


If you use CompoundPropertyModels then wouldn't refactoring your  
business objects will still silently break code?


It seems that ideally you'd just reference a property by its name,  
and continue using things like CompoundPropertyModel,  
PropertyResolver, etc. which accept string representations of  
properties.  Using a code generation tool + generation gap pattern is  
a good way to accomplish this for now, have the code generation  
template generate String constants for all your property names in the  
generated entity superclass java file.


All that said, this is a pretty nifty trick.  I wonder how much it  
will actually benefit developers, though.


-Sam



On Feb 26, 2008, at 10:43 AM, Igor Vaynberg wrote:


not really sure. but this is how it would work.

proxies in cglib take handlers. so you would do:

String key=modelclass.getname();
Class proxy=cache.get(key);
if (proxy==null) {
   proxy=cglib.createproxy(modelclass);
   cache.put(key,proxy);
}
proxyhandler handler=new proxyhandler(this);
Object instance=proxy.getconstructor(handler.class).newinstance 
(handler);


so we reuse the generated proxy class for all instances of the given
model class, and use a fresh handler to intercept all calls to proxy
and build the expression.

-igor



On Tue, Feb 26, 2008 at 10:36 AM, James Carman
[EMAIL PROTECTED] wrote:

So, you would cache the generated class (based on the type passed in)
 and then have it generate a new object each time.  Then, cast that
 object to Factory and set its callbacks?



 On 2/26/08, Igor Vaynberg [EMAIL PROTECTED] wrote:

we can cache the created proxy class and simply give each instance a
 new handler...


 -igor



 On Tue, Feb 26, 2008 at 10:26 AM, James Carman
 [EMAIL PROTECTED] wrote:

Have you tried this out using load testing?  You are creating a new
 class every time you create a model.  Have you run out of permgen
 space?



 On 2/26/08, Sebastiaan van Erk [EMAIL PROTECTED] wrote:

Well, there's a problem with normal PropertyModels (or
 CompoundPropertyModels).

 For example, if you have the following textfield:

 TextField tf = new TextField(name, new PropertyModel(customer,
 customerName));

 Then a refactor of the customerName property (and the  
getCustomerName()
 method) in an IDE such as Eclipse or NetBeans will *silently*  
break the

 above code, which you will discover only at runtime...

 The proxy based approach solves exactly this problem.

 Regards,

Sebastiaan




 atul singh wrote:
I feel this approach does NOT solve a problem.Its just an  
alternative ..


On Tue, Feb 26, 2008 at 4:48 PM, Matej Knopp  
[EMAIL PROTECTED] wrote:



We've reworked the implementation a bit,it works like this:


SafePropertyModelPerson p = new SafePropertyModelPerson 
(new Person());

TextField field = new TextField(name, p.bind(p.property
().getFirstName()));

It's attached to the JIRA issue:
https://issues.apache.org/jira/browse/WICKET-1327

-Matej


On Tue, Feb 26, 2008 at 11:32 AM, Sebastiaan van Erk
[EMAIL PROTECTED] wrote:

Matej Knopp wrote:

Hi,

On Tue, Feb 26, 2008 at 11:13 AM, Sebastiaan van Erk
[EMAIL PROTECTED] wrote:

Matej Knopp wrote:

model.getFirstName() can't really return IModel, if
Customer.getFirstName() returns string.

Anyway, I like the idea, but I don't like the syntax.  
instead of

one
line [add(new TextField(id, model).setRequred(true)) ]  
you have

now

three separate lines.

So I was thinking of something more like

SafePropertyModelCustomer model = new

SafePropertyModelCustomer(customer);


add(new TextField(tf, model.bind(model.proxy

().getCustomerName()

)).setRequired(true));

This way you can have it one one line.

-Matej


 So proxy() returns a Customer proxy?

 And model.bind() takes an Object argument (considering we  
don't

know in

 advance what type getCustomerName() returns)... What about

primitive

 types? Overload bind() for those as well?
Well, the return object is not important at all. What is  
important is
the getCustomerName() call. That marks somewhere in the  
model that

last accessed property was called customerName. and then

immediately

after this model.bind takes this information.


 OK, that's what I described. :-) And I was being stupid  
with respect to
 the overloading. If bind takes an object as argument, then  
overloading

 will not be necessary due to autoboxing. :-)


 And the call to getCustomerName() has the side effect of  
setting a

model
  object somewhere (e.g., in an instance field of model)  
which

 model.bind() can subsequently return?
Model bind will return a model (variation of propertymodel  
probably).
It will take the information that getCustomerName call on  
proxy

provided.


 Ok, so the proxy remembers which getter was called last,  
and you use

 that to construct the model in bind(). Of course.


 Very 

Binding component visibility attribute to another form value

2008-02-25 Thread Sam Barnum
I'm writing a form (non-ajax) in which a selection from a  
DropDownChoice makes various other items on the form visible or  
invisible.


I'd like to bind this behavior up lazily using properties, instead of  
making field variables for all the visible/invisible components.


It seems like writing a custom behavior is the right way to do this,  
but once I call setVisible(false) on a component the beforeRender()  
method in my behavior doesn't get called anymore, and the component  
never becomes visible.


Here's a sketch of the code:

Form form = new Form(form);
add(form);
DropDownChoice report = new DropDownChoice(report ; new  
PropertyModel(this, selectedReport), reportOptions );


WebMarkdupContainer f1 = new WebMarkupContainer(f1);
f1.add(new AbstractBehavior() {
public void onComponentTag(Component component, ComponentTag tag) {
// only show the component if it's enabled for the selected 
report
		component.setVisible(selectedReport != null   
selectedReport.isField1Enabled());

super.onComponentTag(component, tag);
}
} );
form.add(f1);
f1.add(new TextField(myTextField));

It seems like the isTemporary() method in my behavior gets called,  
even if the component is invisible. This hardly seems like the right  
place to put the code, though.


Should I always keep the component visible and have my behavior  
replace all the contents after rendering?


-Sam Barnum



Re: CompoundModel based on proxies

2008-02-07 Thread Sam Barnum
The big argument for this cglib is to introduce some type safety to  
what is currently string-based bindings.  This is a big plus.  I  
don't think it's worth giving up the pure Java aspect that so many  
of us obviously like about Wicket.


I'd rather see some IDE support that is smart about flagging bindings  
which refer to non-existent bean attributes.  That way there's no  
magic or performance hit happening at runtime.  IntelliJ does  
something similar for JPA query Strings.  If a query references a non- 
existent property it appears as an error, even though they're just  
Strings.  Obviously things get really sticky when you're dealing with  
CompoundPropertyModels, etc.


Best case, of course, would be an addition to the java language that  
lets you refer to a property in a type-safe way.  Is there a JSR for  
this?


-Sam Barnum
360Works

On Feb 7, 2008, at 1:50 AM, Maeder Thomas wrote:


+ 1 for what Igor says. I remember debugging Hibernate code: you debug
as far as your own code goes, and then you just guess. Oh, and yes:
Tapestry anyone?

Thomas


-Original Message-
From: Igor Vaynberg [mailto:[EMAIL PROTECTED]
Sent: Donnerstag, 7. Februar 2008 02:34
To: users@wicket.apache.org
Subject: Re: CompoundModel based on proxies

i disagree. i dont think we should be doing more with cglib
in core or any other bytecode magic. have you ever tried to
walk code that uses bytecode generation? its a nightmare. one
of my favorite things about wicket is that it is just java
and its easy as hell to debug. im not really against putting
something like this into extensions, or even having a new
wicket-bytecode/codegen/whatever package that contains things
like these...



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Passing list of POJOs to AutoCompleteTextField?

2008-02-06 Thread Sam Barnum

I've committed a ticket for this, should have mentioned it here:

https://issues.apache.org/jira/browse/WICKET-1324

-sam

On Feb 6, 2008, at 2:47 PM, Michael Mehrle wrote:


I would be happy to - what is the URL for this? (first time - new
contributor).

In that context - I recently grepped through the Wicket source and
noticed that all the javascript event calls (onchange, onclick, etc.)
are all in the code as plain strings, which is bad practice. Thus I
wrote a *JavaScriptUtil* class that has String constants like CHANGE,
BLUR, DRAG_DROP, etc. (and can be statically imported jdk1.5  
style). The

class also includes Javadoc that describes each event in detail. I
thought that this might be a little contribution to Wicket if you want
it. Let me know and I can submit the source (again, would need the URL
and procedure).

Thanks,

Michael

-Original Message-
From: Igor Vaynberg [mailto:[EMAIL PROTECTED]
Sent: Tuesday, February 05, 2008 5:31 PM
To: users@wicket.apache.org
Subject: Re: Passing list of POJOs to AutoCompleteTextField?

please add an rfe into jira for this.

-igor


On Feb 5, 2008 4:38 PM, Michael Mehrle [EMAIL PROTECTED] wrote:

That's exactly what I wound up doing. I wrote my custom renderer that
grabs the name field of my POJO for rendering. Of course that is what
I'm getting back from getModelObjectAsString(). It's a work-around  
and

I

was hoping for a more elegant way of doing this...

Michael


-Original Message-
From: Sam Barnum [mailto:[EMAIL PROTECTED]
Sent: Tuesday, February 05, 2008 4:01 PM
To: users@wicket.apache.org
Subject: Re: Passing list of POJOs to AutoCompleteTextField?

I don't think it is, the getMmodelObject() returns the selected
String.  I've gotten around this by saving the last query string sent
via AJAX.  When the user makes a selection, I iterate over the
options for that query string one more time, and take the POJO whose
rendered string matches the user-selected text.

I'm probably missing something obvious, but I don't think
getModelObject() is it...




--
Sam Barnum
360 Works
http://www.360works.com
415.865.0952



On Feb 5, 2008, at 2:12 PM, Igor Vaynberg wrote:


shouldnt the pojo be availble from getmodelobject()?

-igor


On Jan 29, 2008 11:55 AM, Michael Mehrle [EMAIL PROTECTED]
wrote:

I could - if it was a simple matter of extracting the strings from
the
POJOs. Problem is that, once an option is selected, I need the
underlying POJOs to become the model for the rest of the form. Yes,
there's probably a way to hack this, but I would prefer to do this
in a
clean fashion.

I already got the custom renderer working, so I'm making progress.
Task
#2 now is to grab the underlying POJO after selecting it and

populate

the remainder of the form. This seems to be the tough part...
Again, any
help would be appreciated.

Thanks!!

Michael


-Original Message-
From: Igor Vaynberg [mailto:[EMAIL PROTECTED]
Sent: Tuesday, January 29, 2008 11:47 AM
To: users@wicket.apache.org
Subject: Re: Passing list of POJOs to AutoCompleteTextField?

can you not create an iterator adapter that takes an iterator of
pojos
and translates the pojo to some string?

-igor


On Jan 29, 2008 11:14 AM, Michael Mehrle [EMAIL PROTECTED]
wrote:

I have a working test page containing an AutoCompleteTextField.

Thus

far

the data feeding it has been an Iterator of strings which is being
passed to its overridden getChoices method. So far so good.

What I need to do now is to pass in an Iterator of POJOs instead

and

have the AutoCompleteTextField render the 'name' field inside
each of
those beans. After some digging in the Wicket source I suspect
that I
need to create a custom renderer that does this - am I on the

right

track here or would you guys suggest a different approach?

Another challenge will be to populate other form fields in the

page

after selecting an option from the AutoCompleteTextField. By
selecting
an option in the dropdown I am basically selecting an entire POJO,

which

is supposed to be used as the model for the other remaining

fields.

For

instance, the POJO will contain address, zip, phone, etc. fields

and

by

selecting the appropriate name in the AutoCompleteTextField it

populates

all other fields with the remaining data in the underlying POJO.
Hope
this makes sense - I think I have an idea of how to implement

this,

but

would appreciate any tips/insights.

Thanks!!

Michael










-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






-

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED

Re: html hotswap

2008-02-05 Thread Sam Barnum
I use IntelliJ for wicket development, and for the most part am  
pretty happy with it.


When I make a change, I do a build, and IntelliJ asks if I want to  
redeploy the application.  If I haven't changed any java method  
signatures, I click 'no' and my HTML changes and java changes are live.


That said, there are a few caveats. Sometimes things seem a little  
weird after doing a hot swap, particularly persistent objects.  But  
the biggie:


There's a checkbox in the redeploy dialog saying don't ask me  
again.  If you check this, there's no way to bring back this dialog,  
and your app will be redeployed every time you do a build!  The  
solution is to quit intellij and manually edit your .ipr file.   
Remove the line that says


option name=DEPLOY_AFTER_MAKE value=1 /

I've just mustered up the effort to submit a feature request on this  
to jetbrains.


I strongly recommend you get the WicketForge IntelliJ plugin as well,  
it's quite helpful for identifying wicket:id attribtues in your HTML  
file which don't match a component in your java file.


--
Sam Barnum
360 Works
http://www.360works.com
415.865.0952



On Feb 5, 2008, at 11:32 AM, [EMAIL PROTECTED] wrote:


Hello.

I was wondering the same thing. I also came across a page that  
might answer

the question as well:
http://wicket.sourceforge.net/wicket-1.0/faqs.html#how-reload- 
changed-markup

-files

Good luck,

Bruce.

-Original Message-
From: Igor Vaynberg [mailto:[EMAIL PROTECTED]
Sent: Tuesday, 05 February, 2008 11:17 AM
To: users@wicket.apache.org
Subject: Re: html hotswap

are you configuring wicket in development mode or in deployment mode?
in development mode wicket will reload changed resources like html and
.properties files automatically.

-igor


On Feb 5, 2008 11:12 AM, JSP lover [EMAIL PROTECTED] wrote:


Hi,

   Excuse me for my ignorance, but my team just started to play with

Wicket

and I am having a hard time with it.
   My problem is that I am used to changing the HTML of a page,  
getting it
just right. So in the process of developing a page I may review  
changes to

it many many times.Add a div here, add a div there and review the
changes.
Now, if I make changes using the wicket framework, at least in  
intelliJ it

seems that I have to reinitialize the server. If I have to reinit the

server
for every little html change I feel that my productivity goes to   
0 and

frustration to 100!

What am I missing?

Thanks.
--
View this message in context:

http://www.nabble.com/html-hotswap-tp15297400p15297400.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]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





Re: Passing list of POJOs to AutoCompleteTextField?

2008-02-05 Thread Sam Barnum
I don't think it is, the getMmodelObject() returns the selected  
String.  I've gotten around this by saving the last query string sent  
via AJAX.  When the user makes a selection, I iterate over the  
options for that query string one more time, and take the POJO whose  
rendered string matches the user-selected text.


I'm probably missing something obvious, but I don't think  
getModelObject() is it...





--
Sam Barnum
360 Works
http://www.360works.com
415.865.0952



On Feb 5, 2008, at 2:12 PM, Igor Vaynberg wrote:


shouldnt the pojo be availble from getmodelobject()?

-igor


On Jan 29, 2008 11:55 AM, Michael Mehrle [EMAIL PROTECTED]  
wrote:
I could - if it was a simple matter of extracting the strings from  
the

POJOs. Problem is that, once an option is selected, I need the
underlying POJOs to become the model for the rest of the form. Yes,
there's probably a way to hack this, but I would prefer to do this  
in a

clean fashion.

I already got the custom renderer working, so I'm making progress.  
Task

#2 now is to grab the underlying POJO after selecting it and populate
the remainder of the form. This seems to be the tough part...  
Again, any

help would be appreciated.

Thanks!!

Michael


-Original Message-
From: Igor Vaynberg [mailto:[EMAIL PROTECTED]
Sent: Tuesday, January 29, 2008 11:47 AM
To: users@wicket.apache.org
Subject: Re: Passing list of POJOs to AutoCompleteTextField?

can you not create an iterator adapter that takes an iterator of  
pojos

and translates the pojo to some string?

-igor


On Jan 29, 2008 11:14 AM, Michael Mehrle [EMAIL PROTECTED]  
wrote:

I have a working test page containing an AutoCompleteTextField. Thus

far

the data feeding it has been an Iterator of strings which is being
passed to its overridden getChoices method. So far so good.

What I need to do now is to pass in an Iterator of POJOs instead and
have the AutoCompleteTextField render the 'name' field inside  
each of
those beans. After some digging in the Wicket source I suspect  
that I

need to create a custom renderer that does this - am I on the right
track here or would you guys suggest a different approach?

Another challenge will be to populate other form fields in the page
after selecting an option from the AutoCompleteTextField. By  
selecting

an option in the dropdown I am basically selecting an entire POJO,

which

is supposed to be used as the model for the other remaining fields.

For

instance, the POJO will contain address, zip, phone, etc. fields and

by

selecting the appropriate name in the AutoCompleteTextField it

populates
all other fields with the remaining data in the underlying POJO.  
Hope

this makes sense - I think I have an idea of how to implement this,

but

would appreciate any tips/insights.

Thanks!!

Michael




 
-

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





Using detachable models in edit pages

2008-02-01 Thread Sam Barnum
Good explanation, I wasn't aware that was how it worked.  Time to  
switch all my edit pages to use detachable models!


One more question on this topic (changing the subject of the thread)

Consider the scenario:

* Your edit page uses a detachable model to hold your business object.
* The user edits an object succesfully.
* On a later page, the user deletes the object.
* Then uses the back button to navigate back to the edit page, and  
hits reload, or tries saving the object again.


The detachable model will fire, and will fail to load the object from  
the DB.  Depending on how your DAO is implemented, this will either  
return null or throw an exception.  Do you have a recommendation on  
how to handle this scenario?  Would you just check for null/catch the  
exception and do a redirect to an error message page?


Thanks!

On Jan 31, 2008, at 7:23 PM, Nick Heudecker wrote:


Answer inline.

On Jan 31, 2008 8:42 PM, Sam Barnum [EMAIL PROTECTED] wrote:


Question on detachable models:

You use detachable models in the contact edit page.  It seems like
this would cause your changes to be lost if the edit process takes
more than one request to complete.

If you use the no-arg constructor, the loadableDetachableModel
creates a new contact at the beginning of every request.  If you
enter a name that's too long, a validation message is displayed. Then
the detach() is called on the model, and a new Contact is loaded on
the next request, erasing your temporary changes.



If validation fails, the input isn't copied to the Contact object.   
The form

input is only copied to the Contact object when the form successfully
submits.





I may well be misunderstanding something, I'm fairly new to this
stuff.  It seems that for edit pages you want a non-detachable model,
which gets serialized to the session.



I had the same misconception when I started using  Wicket.





Thanks for taking the time to write this article, and thanks in
advance for any clarification on this topic.

--
Sam Barnum
360 Works
http://www.360works.com
415.865.0952



On Jan 28, 2008, at 11:02 AM, Nick Heudecker wrote:


It's finally up:
http://www.theserverside.com/news/thread.tss?thread_id=48234

Thanks to the various reviewers that helped improve both the
content and
quality of the article, including Martijn, Eelco, Igor, Gerolf and
Talios.

--
Nick Heudecker
Professional Wicket Training  Consulting
http://www.systemmobile.com

Eventful - Intelligent Event Management
http://www.eventfulhq.com






--
Nick Heudecker
Professional Wicket Training  Consulting
http://www.systemmobile.com

Eventful - Intelligent Event Management
http://www.eventfulhq.com



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Article: Introducing Apache Wicket

2008-01-31 Thread Sam Barnum

Question on detachable models:

You use detachable models in the contact edit page.  It seems like  
this would cause your changes to be lost if the edit process takes  
more than one request to complete.


If you use the no-arg constructor, the loadableDetachableModel  
creates a new contact at the beginning of every request.  If you  
enter a name that's too long, a validation message is displayed. Then  
the detach() is called on the model, and a new Contact is loaded on  
the next request, erasing your temporary changes.


I may well be misunderstanding something, I'm fairly new to this  
stuff.  It seems that for edit pages you want a non-detachable model,  
which gets serialized to the session.


Thanks for taking the time to write this article, and thanks in  
advance for any clarification on this topic.


--
Sam Barnum
360 Works
http://www.360works.com
415.865.0952



On Jan 28, 2008, at 11:02 AM, Nick Heudecker wrote:


It's finally up:
http://www.theserverside.com/news/thread.tss?thread_id=48234

Thanks to the various reviewers that helped improve both the  
content and
quality of the article, including Martijn, Eelco, Igor, Gerolf and  
Talios.


--
Nick Heudecker
Professional Wicket Training  Consulting
http://www.systemmobile.com

Eventful - Intelligent Event Management
http://www.eventfulhq.com




Custom components which accept multiple models

2008-01-30 Thread Sam Barnum
I'm writing an settings admin page for editing a bunch of Boolean  
settings.  I'm using a custom component to edit the boolean values.   
This custom component needs access to two settings objects  
(masterSettings, customSettings) to determine if a custom setting is  
overridden by a master setting.


some pseudocode:

public class SettingsEditPage extends WebPage {

	public SettingsEditPage(Settings masterSettings, Settings  
customSettings) {
		Model masterModel = new CompoundPropertyModel(new  
LoadableDetachableModel(masterSettings){/* load method omitted */});
		Model cutomModel = new CompoundPropertyModel(new  
LoadableDetachableModel(customSettings){/* load method omitted */});

//
		add(new SettingsEditComponent(canDeleteWidgets, masterModel,  
customModel));
		add(new SettingsEditComponent(canCreateWidgets, masterModel,  
customModel));
		add(new SettingsEditComponent(allowsReturns, masterModel,  
customModel));

}
}

I'd like to use the component id for the SettingsEditComponent as a  
property expression, like in a CompoundPropertyModel.  This would be  
used to query the master settings first. If that returns null, use  
the value from the custom settings.  I also need the ability to  
display to the user whether a value came from the masterSettings or  
customSettings.


It's not clear to me what the best way to architect this is.

Should I make a custom model that wraps both the masterSettings and  
customSettings objects? It would need a boolean method to determine  
whether a given propertyExpression is taken from the master or custom  
settings.  If I do this, the SettingsEditComponent constructor would  
need to only accept that specific model type (or an interface with  
the boolean method, which is overkill).


Or, should I pass both settings objects into the  
SettingsEditComponent, as pictured above?  It seems like it would be  
harder to have detachable models in this case (I guess I'd just need  
to override detatchModels()).


Or, some other option that I'm missing...

Thanks!

--
Sam Barnum
http://www.360works.com
415.865.0952





image uploads and file locations

2008-01-14 Thread Sam Barnum
Any suggestions or best practices on how to handle image uploads?   
I'm planning on saving uploaded images as files (not BLOBs) and  
serving up resized versions of the images.


In particular:

Is there a good standard place to store the full-res files in a  
wicket application?


Should I serve the resized versions via wicket, or instead try to  
save them in a folder which is served directly by my webserver?   
These won't be in the classes directory, since I don't want them  
wiped out during redeployment.


Thanks in advance,

Sam Barnum



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Dont refresh webpage on Form Submit

2008-01-10 Thread Sam Barnum

You might be thinking of an onsubmit javascript that returns false.

form onsubmit=return confirm('Are you sure you want to submit this  
form?').../form


You could add the onsubmit attribute dynamically, and it could  
presumably call wicket with some sort of ajax behavior (still haven't  
gone there).


--
Sam Barnum
360 Works
http://www.360works.com
415.865.0952



On Jan 10, 2008, at 7:14 PM, Haritha Juturu wrote:


Hi Everyone,
I have a Form object in my wicket page. After the onSubmit() method  
is called the webpage is refreshed.
Is there anyway i can stop the webpage reload after the onSubmit()  
method is executed.

Thanks
Haritha





   
__ 
__

Be a better friend, newshound, and
know-it-all with Yahoo! Mobile.  Try it now.  http:// 
mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ




Re: required for Checkbox

2008-01-08 Thread Sam Barnum
Right, like for an accept terms checkbox after some legalese stuff,  
for example.


On Jan 7, 2008, at 5:09 PM, Kent Tong wrote:





Dan Kaplan-3 wrote:


But another way to look at it is this: When a checkbox is  
unchecked, it

has
a value of unchecked.  Therefore, if you setRequired=true on a  
checkbox,
it's always satisfied.  In otherwords, a checkbox always has a  
value so

setRequired=true has no effect on a checkbox.



Yeah, that's exactly the correct behavior in my mind.


-
--
Kent Tong
Wicket tutorials freely available at http://www.agileskills2.org/EWDW
Axis2 tutorials freely available at http://www.agileskills2.org/DWSAA
--
View this message in context: http://www.nabble.com/%22required%22- 
for-Checkbox-tp14662131p14680214.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]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]