Re: SimpleAuthorizationStratagy with errormessage fails

2009-06-07 Thread Cuball

I didn't find a solution yet :-(

anyone an idea how to solve my problem ?



Cuball wrote:
> 
> Hi all,
> 
>  
> 
> I have a created a simple authorizationstrategy,
> 
>  
> 
>SimplePageAuthorizationStrategy authorizationStrategy = new
> SimplePageAuthorizationStrategy(
> 
>   OnlineVacationAvailabilityPage.class,
> VacationAlreadyRegisteredPage.class) {
> 
>   protected boolean isAuthorized()  {
> 
> return
> (((VacationApplicationSession)Session.get()).getBookingInformation() ==
> null);
> 
> }
> 
>};
> 
>  
> 
>  
> getSecuritySettings().setAuthorizationStrategy(authorizationStrategy);
> 
>  
> 
>  
> 
> I want the user to visit the OnlineVacationAvailabiltyPage only when
> he's authorized (= there's no bookingInformation in the session).  When
> a execute the following scenario (it's a bit of a reverse login
> scenario, but it should work ;-) :
> 
>  
> 
> (first visit)
> 
> *user enters the OnlineVacationAvailabiltyPage -> isAuthorized returns
> true because there is no booking information in the session (= OK)
> 
> *users enters information and submits page -> program creates a
> bookingInformation object in the session (= OK)
> 
> *users clicks back button of the browser -> isAuthorized returns false
> because there is a booking information available in the session, the
> user is redirected to the VacationAlreadyRegisteredPage (= OK)
> 
>  
> 
> The above works as it should, but the following scenario doesn't
> 
>  
> 
> (first visit)
> 
> *user enters the OnlineVacationAvailabiltyPage -> isAuthorized returns
> true because there is no booking information in the session (= OK)
> 
> *users enters informations and submits page -> there is a validation
> error in the onSubmit action, error(message) is called and the user
> returns to the OnlineVactionAvailabiltyPage (but now it's not a
> stateless page anymore because there is an error message shown to the
> user) (=OK)
> 
> *users enters correct information and submits page -> program creates a
> bookingInformation object in the session (=OK)
> 
> *users clicks back button of the browser -> the isAhtorized method isn't
> called anymore and the user returns to the OnlineAvailibiltyPage ( NOT
> OK )
> 
>  
> 
> I thinks this happens because after the error occurred my page isn't
> stateless anymore L
> 
>  
> 
> Any ideas how to solve this ?
> 
>  
> 
> Regards,
> 
> Joeri
> 
>  
> 
>  
> 
>  
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/SimpleAuthorizationStratagy-with-errormessage-fails-tp23706873p23918821.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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



AW: Custom HeaderContributor

2009-06-07 Thread Stefan Lindner
Hello Jeremy,

you wrote "HeaderContributor is rather an implementation of IHeaderContributor 
- of which of course you could create your own implementations"

Great to read, but how can I do this?

-Ursprüngliche Nachricht-
Von: Jeremy Thomerson [mailto:jer...@wickettraining.com] 
Gesendet: Montag, 8. Juni 2009 02:22
An: users@wicket.apache.org
Betreff: Re: Custom HeaderContributor

HeaderContributor is rather an implementation of IHeaderContributor -
of which of course you could create your own implementations.  What
you really seem to be seeking is to make each ajax behavior use a
different header contributor.  For that, you would need to override
the way which each ajax behavior contributes script.

--
Jeremy Thomerson
http://www.wickettraining.com




On Sun, Jun 7, 2009 at 12:25 PM, Stefan Lindner  wrote:
> OK :-)
> When I create a special AjaxBehavior I can overwrite the onRenderHead method 
> which has an IHeaderContributor (=Header Contributor) as parameterJavaScript 
> to the page's  section.
> But every AjaxBehavior renders it's own  tag. I there 
> are a lot of such AjaxBehaviors on a page then the header contains a huge 
> number of ... sections with only a few characters of 
> javascript inside.
> I found no possibility to combine all the small pieces in one 
>  section.
> So my idea was to use my own, extended version of HeaderContributor. Just 
> like I can have a own version of Session. But where can I direct Wicket to 
> use my extended version of HeaderContributor?
>
> 
>
> Von: Martin Funk [mailto:mafulaf...@googlemail.com]
> Gesendet: So 07.06.2009 19:00
> An: users@wicket.apache.org
> Betreff: Re: Custom HeaderContributor
>
>
>
>
> Am 07.06.2009 um 18:43 schrieb Stefan Lindner:
>
>> Is it possible to have a custom HeaderContributor?
>
> err... could you elaborate a little more?
>>
>>
>>
>> -
>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>> For additional commands, e-mail: users-h...@wicket.apache.org
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>
>
>
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>

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


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



Re: wicket:link -> wicket:context

2009-06-07 Thread Jeremy Thomerson
See org.apache.wicket.markup.resolver.AutoLinkResolver

--
Jeremy Thomerson
http://www.wickettraining.com




On Sat, Jun 6, 2009 at 5:00 PM, Luther Baker  wrote:
> I'd like to consider writing a component similar to wicket:link.
>
> I don't think wicket:link actually does the dirty work. My cursory view at
> the source suggests that wicket:link sets a flag and some other classes
> update the actual path printed to the page. Is this an established or
> documented pattern that I could follow for implementing something like
> wicket:context? I have WIA but didn't recognize this type of component
> discussed.
>
> Igor mentioned:
>
>> it may be helpful to create  analog of , we
> already have the framework for getting the path prefix to get to contextpath
>
> Likely it is obvious - but would someone be able to briefly elaborate on the
> 'framework' Igor mentions here ... or anyone care to map out a high level
> class or object blueprint of what I might look at or how to make this
> happen?
>
> Any suggestions would be appreciated.
>
> Thanks,
>
> -Luther
>

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



Re: Custom HeaderContributor

2009-06-07 Thread Jeremy Thomerson
HeaderContributor is rather an implementation of IHeaderContributor -
of which of course you could create your own implementations.  What
you really seem to be seeking is to make each ajax behavior use a
different header contributor.  For that, you would need to override
the way which each ajax behavior contributes script.

--
Jeremy Thomerson
http://www.wickettraining.com




On Sun, Jun 7, 2009 at 12:25 PM, Stefan Lindner  wrote:
> OK :-)
> When I create a special AjaxBehavior I can overwrite the onRenderHead method 
> which has an IHeaderContributor (=Header Contributor) as parameterJavaScript 
> to the page's  section.
> But every AjaxBehavior renders it's own  tag. I there 
> are a lot of such AjaxBehaviors on a page then the header contains a huge 
> number of ... sections with only a few characters of 
> javascript inside.
> I found no possibility to combine all the small pieces in one 
>  section.
> So my idea was to use my own, extended version of HeaderContributor. Just 
> like I can have a own version of Session. But where can I direct Wicket to 
> use my extended version of HeaderContributor?
>
> 
>
> Von: Martin Funk [mailto:mafulaf...@googlemail.com]
> Gesendet: So 07.06.2009 19:00
> An: users@wicket.apache.org
> Betreff: Re: Custom HeaderContributor
>
>
>
>
> Am 07.06.2009 um 18:43 schrieb Stefan Lindner:
>
>> Is it possible to have a custom HeaderContributor?
>
> err... could you elaborate a little more?
>>
>>
>>
>> -
>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>> For additional commands, e-mail: users-h...@wicket.apache.org
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>
>
>
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>

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



Re: [Bug 1.3.6] Inconsistent RequestUtils.toAbsolutePath()

2009-06-07 Thread Johan Compagner
please attach a failing test case

On Sun, Jun 7, 2009 at 21:16, smallufo  wrote:

> 2009/6/8 Johan Compagner 
>
> > that it doesnt give you the hostname/port is ofcourse a bug
>
>
>
> I've submitted this bug to JIRA :
> https://issues.apache.org/jira/browse/WICKET-2312
>


Re: [Bug 1.3.6] Inconsistent RequestUtils.toAbsolutePath()

2009-06-07 Thread smallufo
2009/6/8 Johan Compagner 

> that it doesnt give you the hostname/port is ofcourse a bug



I've submitted this bug to JIRA :
https://issues.apache.org/jira/browse/WICKET-2312


Re: [Bug 1.3.6] Inconsistent RequestUtils.toAbsolutePath()

2009-06-07 Thread Johan Compagner
that it doesnt give you the hostname/port is ofcourse a bug

print out these variables:

getRequestCycle().urlFor(CurrentPage.class ,pps).toString()

I think that one time it will give you just the url
and one time

../.././CurrentPage

i guess that is your problem but you need to debug a bit more why it gives
you that ../../




On Sun, Jun 7, 2009 at 20:14, smallufo  wrote:

> Is there a plan to make behavior of RequestUtils.toAbsolutePath
> (inside/outside AJAX) identical ?
>
> If no , the only way to get the "correct" absolute URL in the AJAX
> onClick()
> is pre-appending host name / port / context name ...
> I think it is so cumbersome
>
>
> 2009/6/8 Martin Makundi 
>
> > The problem is that when you have a bookmarkable page with parameters,
> > the url looks like this:
> >
> > http://www.mydomain.com/myapp/MyPage/param1/value1/param2/value2
> >
> > The parameters are not part of the url path, but the "toAbsolutePath"
> > code assumes them to be.
> >
> > It would be better if it would adapt to the used url encoding and
> > strip page parameters.
> >
> > **
> > Martin
> >
>


Re: [Bug 1.3.6] Inconsistent RequestUtils.toAbsolutePath()

2009-06-07 Thread smallufo
Is there a plan to make behavior of RequestUtils.toAbsolutePath
(inside/outside AJAX) identical ?

If no , the only way to get the "correct" absolute URL in the AJAX onClick()
is pre-appending host name / port / context name ...
I think it is so cumbersome


2009/6/8 Martin Makundi 

> The problem is that when you have a bookmarkable page with parameters,
> the url looks like this:
>
> http://www.mydomain.com/myapp/MyPage/param1/value1/param2/value2
>
> The parameters are not part of the url path, but the "toAbsolutePath"
> code assumes them to be.
>
> It would be better if it would adapt to the used url encoding and
> strip page parameters.
>
> **
> Martin
>


Component lifecycle question

2009-06-07 Thread Martin Funk

Hi list,

in short:

Why is there no Component#onRemove() method?

I see that there is Component#onDetach() which is called by  
Component#remove(), so it might be a good candidate.

But onDetach is also called at the end of every RequestCycle.
I have things that I want to get done when a Component is removed or  
replaced, not on every detach.


How can I achieve that?

mf

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



RE: Custom HeaderContributor

2009-06-07 Thread Stefan Lindner
OK :-)
When I create a special AjaxBehavior I can overwrite the onRenderHead method 
which has an IHeaderContributor (=Header Contributor) as parameterJavaScript to 
the page's  section.
But every AjaxBehavior renders it's own  tag. I there are 
a lot of such AjaxBehaviors on a page then the header contains a huge number of 
... sections with only a few characters of javascript inside.
I found no possibility to combine all the small pieces in one 
 section.
So my idea was to use my own, extended version of HeaderContributor. Just like 
I can have a own version of Session. But where can I direct Wicket to use my 
extended version of HeaderContributor?



Von: Martin Funk [mailto:mafulaf...@googlemail.com]
Gesendet: So 07.06.2009 19:00
An: users@wicket.apache.org
Betreff: Re: Custom HeaderContributor




Am 07.06.2009 um 18:43 schrieb Stefan Lindner:

> Is it possible to have a custom HeaderContributor?

err... could you elaborate a little more?
>
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org


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





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

Re: [Bug 1.3.6] Inconsistent RequestUtils.toAbsolutePath()

2009-06-07 Thread Martin Makundi
The problem is that when you have a bookmarkable page with parameters,
the url looks like this:

http://www.mydomain.com/myapp/MyPage/param1/value1/param2/value2

The parameters are not part of the url path, but the "toAbsolutePath"
code assumes them to be.

It would be better if it would adapt to the used url encoding and
strip page parameters.

**
Martin

2009/6/7 Johan Compagner :
> No it is just the request uri and the request uri of the ajax call will
> always be
>
> http://foo.bar:8080/app/?xx=y
>
>
> so that is correct.
>
> And looking at the code you also can see that that last piece CurrentPage is
> stripped out (as it should) in the make to absolute path code
>
> Just Debug it
>
>
>
>
> On Sun, Jun 7, 2009 at 19:03, smallufo  wrote:
>
>> 2009/6/7 Johan Compagner 
>>
>> > >
>> > >
>> > >
>> > >
>> > > a1 = http://foo.bar:8080/app/CurrentPage
>> > > s1 = http://foo.bar:8080/app/CurrentPage
>> > >
>> > > a2 = http://foo.bar:8080/app/
>> > > s2 = http://CurrentPage/  
>> > >
>> > >
>> > > a1 , s1 are correct ,
>> > > a2 , s2 are totally wrong.
>> > >
>> >
>> >
>> >
>> > a1 , s1 en a2 are all correct.
>> >
>> > but why s2 is a result when a2 is the input for that toAbsolutePath is
>> > weird.
>>
>>
>> Why a2 is correct ?
>> I think a2 should be identical to a1 (and s1) ...
>>
>

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



Stateful vs stateless requests and navigation

2009-06-07 Thread J.-F. Rompre
Hello all,

I have a question regarding the way wicket treats session- versus stateless-
requests when
accessed outside the app. navigation (back/forward buttons, "BFBs").

Ideally my navigation 'robustness' goal is for the user to be able to use
BFBs to view pages accordingly, but without reversing changes to the
shopping cart, or displaying inaccuracies (such as updating the cart,
hitting the BB and looking at the cached page with old cart content).


SETUP A
So I tried setting the response headers to 'no-cache','no-store' as
prescribed in other threads - that forces each request to go to the server
and fixed the accuracy problem. - cart contents were then always accurate.
However all stateless- requests such as paging URLs got rejected with 'Page
expired', even though the session is obviously live (versions keep getting
incremented
using app. navigation for stateful requests, shopping cart is OK, etc..).

SETUP B
Next I tried URLHybridCodingStrategy combined with the 'no-cache',
'no-store' header config. and that removed the 'Page expired' problem.
However, I still can't access the previous screen when it was accessed with
a stateful request such as pagination: instead, the user is sent back to the
beginning of the pageable list.


Also, with my current setup B above, I am expecting page instances to be
reused when accessed within a session: however new page instances are
created for each single request except for pagination requests - those go to
the latest version, I assume.


So my question is two-fold:

1) Does setting no-cache and/or no-store in the header cause the page map to
keep only the current version, or older verions to be inaccessible via the
request URL?  I know that 'Page Expired' can have other causes e.g.
serialization issues, but if that was the case here then setup B would have
failed as well? Unless the problem exists in both cases both is 'skipped
over' by the HybridUrlCodingStrategy?

2) What drives the decision to reuse page instances, other than
non-bookmarkability?

Any comment or pointer to existing documentation is greatly appreciated.

Thanks,

JF


Re: [Bug 1.3.6] Inconsistent RequestUtils.toAbsolutePath()

2009-06-07 Thread Johan Compagner
No it is just the request uri and the request uri of the ajax call will
always be

http://foo.bar:8080/app/?xx=y


so that is correct.

And looking at the code you also can see that that last piece CurrentPage is
stripped out (as it should) in the make to absolute path code

Just Debug it




On Sun, Jun 7, 2009 at 19:03, smallufo  wrote:

> 2009/6/7 Johan Compagner 
>
> > >
> > >
> > >
> > >
> > > a1 = http://foo.bar:8080/app/CurrentPage
> > > s1 = http://foo.bar:8080/app/CurrentPage
> > >
> > > a2 = http://foo.bar:8080/app/
> > > s2 = http://CurrentPage/  
> > >
> > >
> > > a1 , s1 are correct ,
> > > a2 , s2 are totally wrong.
> > >
> >
> >
> >
> > a1 , s1 en a2 are all correct.
> >
> > but why s2 is a result when a2 is the input for that toAbsolutePath is
> > weird.
>
>
> Why a2 is correct ?
> I think a2 should be identical to a1 (and s1) ...
>


Re: [Bug 1.3.6] Inconsistent RequestUtils.toAbsolutePath()

2009-06-07 Thread smallufo
2009/6/7 Johan Compagner 

> >
> >
> >
> >
> > a1 = http://foo.bar:8080/app/CurrentPage
> > s1 = http://foo.bar:8080/app/CurrentPage
> >
> > a2 = http://foo.bar:8080/app/
> > s2 = http://CurrentPage/ 
> >
> >
> > a1 , s1 are correct ,
> > a2 , s2 are totally wrong.
> >
>
>
>
> a1 , s1 en a2 are all correct.
>
> but why s2 is a result when a2 is the input for that toAbsolutePath is
> weird.


Why a2 is correct ?
I think a2 should be identical to a1 (and s1) ...


Re: Custom HeaderContributor

2009-06-07 Thread Martin Funk


Am 07.06.2009 um 18:43 schrieb Stefan Lindner:


Is it possible to have a custom HeaderContributor?


err... could you elaborate a little more?




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



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



Custom HeaderContributor

2009-06-07 Thread Stefan Lindner
Is it possible to have a custom HeaderContributor?


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

Re: Copy Form Fields

2009-06-07 Thread hill180
This might not be the best solutions (new to wicket/java) but I posted  
if it might help:
This way, I was able to copy the fields and save correctly to my  
Hibernate POJO.



package com.myapp.wicket;

import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.model.Model;

/**
 *
 * @author hill180
 */
public final class HomePage extends WebPage {
@SuppressWarnings("unchecked")
public HomePage() {
super ();
Model firstAddress = new Model("test");//Simulated info from DB

Model secondAddress = new Model("");
Form form = new Form("form"){

@Override
protected void onSubmit() {
super.onSubmit();//TODO
}

};
form.setOutputMarkupId(true);
TextField textFirstAddress = new TextField("firstAddress",  
firstAddress);

textFirstAddress.setOutputMarkupId(true);
TextField textSecondAddress = new TextField("secondAddress",  
secondAddress);

textSecondAddress.setOutputMarkupId(true);
add(form);
form.add(textFirstAddress);
form.add(textSecondAddress);
Label label = new Label("copyAddress", "click here");
String ajaxFirstAddressName = textFirstAddress.getMarkupId();
String ajaxSecondAddressName = textSecondAddress.getMarkupId();
String ajaxFormName = form.getMarkupId();
label.add(new AttributeAppender("onclick", new Model(
ajaxFormName + "." + ajaxSecondAddressName + ".value  
= " + ajaxFormName + "." + ajaxFirstAddressName + ".value;"), ";"));

form.add(label);

}


}



On Jun 4, 2009, at 5:26 AM, Eyal Golan wrote:


hhhmm...
I'm not a Hibernate expert, but what if your POJO will be detached?

Eyal Golan
egola...@gmail.com

Visit: http://jvdrums.sourceforge.net/
LinkedIn: http://www.linkedin.com/in/egolan74

P  Save a tree. Please don't print this e-mail unless it's really  
necessary



On Wed, Jun 3, 2009 at 11:02 PM, hill180  wrote:


apparently no.

it may just be my understanding.

Because the modal is from a compoundproperty that is a hibernate  
POJO, this
will copy what is in the "database" over, not what is in the field  
over.


I hope I am explaining myself.

-jose


On Jun 1, 2009, at 8:25 AM, Eyal Golan wrote:

I though more something like this:

AjaxLink link = new AjaxLink("copyAddress"){
@Override
public void onClick(AjaxRequestTarget target) {
this.address2 = this.address1;
   target.addComponent(myAddress2);
}
};//end of Link

wouldn't that work?

Eyal Golan
egola...@gmail.com

Visit: http://jvdrums.sourceforge.net/
LinkedIn: http://www.linkedin.com/in/egolan74

P  Save a tree. Please don't print this e-mail unless it's really
necessary


On Mon, Jun 1, 2009 at 5:31 PM, hill180  wrote:

AjaxLink link = new AjaxLink("copyAddress"){



@Override
public void onClick(AjaxRequestTarget target) {
myAddress2.setModelObject(myAddress1.getValue());
   target.addComponent(myAddress2);
}
};//end of Link


This kinda works.  It does update the MyAddress2 Field, but if I  
change
myAddress1 and click on the click, it will get the original value  
of

myAddress1, not the value inside of the forms textfield.


-jose


On Jun 1, 2009, at 1:48 AM, Eyal Golan wrote:

I'm not sure, but give it a try:

In the onClick, set the property address2 to be the same as  
property

address1.
Add myAddress2 to the target.

If you use compoundpropertymodel, it should work.

Eyal Golan
egola...@gmail.com

Visit: http://jvdrums.sourceforge.net/
LinkedIn: http://www.linkedin.com/in/egolan74

P  Save a tree. Please don't print this e-mail unless it's really
necessary


On Mon, Jun 1, 2009 at 12:55 AM, hill180   
wrote:


I have looked through the archives and there were a couple  
references to



this question but no examples and I was hoping for some help.

I have a form with Address One and Address Two,

I have a link that I just want to copy the data over.  I am  
thinking it

should use Javascript, but I am new to wicket and not sure how to
implement.

The textfields are a compound property model which is hitting a
hibernate
POJO.


private static class AddressPanel extends Panel
{

  public AddressPanel(String id, Form f,final AssociateDB a)
  {
super(id);
final TextField myAddress1 = new  
TextField("Address1"); //

First Address
add(myAddress1);
  final TextField myAddress2 = new  
TextField("Address2"); //

First Address
   myAddress2.setOutputMarkupId(true);
  add(myAddress2);


  Link link = new Link("copyAddress"){
  @Override
  //TODO ADD JAVASCRIPT COPY, FAILS TO SAVE

Re: nested forms and locale

2009-06-07 Thread Morten Steffensen
Well - when I click one of the links for changing the locale, after i 
hit the "Press me" button, the onClick method gets called, and the 
setLocale gets called. Then i thought that the setLocale would mark the 
session as dirty and in some magic way the models getObject gets called 
on the items of the page.. hmm.




Brill Pappin wrote:
i may be wrong about this because my wicket ajax is still a bit shaky, 
but try adding the components you wanted updated to the links target.


- Brill

On 7-Jun-09, at 10:20 AM, Morten Steffensen wrote:


Hi,
I am having problems using nested forms and changing locale.

I have 2 links for changing the locale. It works until i press the 
AjaxButton in the inner form. Hereafter the txtField's getObject is 
not called anymore.


What am i doing wrong ? Any suggestions ?



public class ProblemPage extends WebPage {
  private Map map = new HashMap();

  public ProblemPage() {
  map.put("en", "Hello");
  map.put("da", "Goddag");

  getSession().setLocale(new Locale("en", "EN"));

  add(new Link("enLocale")
  {
  public void onClick() {
  getSession().setLocale(new Locale("en", "EN"));
  }
  });
  add(new Link("daLocale")
  {
  public void onClick() {
  getSession().setLocale(new Locale("da", "DK"));
  }
  });

  Form outerform = new Form("outerform") {
  protected void onSubmit() {
  super.onSubmit();
  }
  };
  add(outerform);

  TextField txtField = new TextField("txtfield",new Model() {
  public Object getObject() {
  return map.get(getSession().getLocale().getLanguage());
  }

  public void setObject(Object o) {
  map.put(getSession().getLocale().getLanguage(),(String)o);
  }
  });
  outerform.add(txtField);

  Form innerform = new Form("innerform") {
  protected void onSubmit() {
  super.onSubmit();
  }
  };
  outerform.add(innerform);

  AjaxButton editButton= new AjaxButton("pressmeButton")
  {
  protected void onSubmit(AjaxRequestTarget target, Form form)
  {
  super.onSubmit();
  }
  };
  editButton.add(new SimpleAttributeModifier("value","Press me"));
//editButton.setDefaultFormProcessing(false);
  innerform.add(editButton);


  outerform.add(new AjaxButton("submitButton") {
  protected void onSubmit(AjaxRequestTarget target, Form form)
  {
  super.onSubmit();
  }
  });
  }
}








English
Danish


  

  
  
  

  








--
Kinds regards,
Morten Steffensen



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




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




--
Med venlig hilsen / kinds regards,
Morten Steffensen

Emercos ApS
www.emercos.com


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



Re: nested forms and locale

2009-06-07 Thread Brill Pappin
i may be wrong about this because my wicket ajax is still a bit shaky,  
but try adding the components you wanted updated to the links target.


- Brill

On 7-Jun-09, at 10:20 AM, Morten Steffensen wrote:


Hi,
I am having problems using nested forms and changing locale.

I have 2 links for changing the locale. It works until i press the  
AjaxButton in the inner form. Hereafter the txtField's getObject is  
not called anymore.


What am i doing wrong ? Any suggestions ?



public class ProblemPage extends WebPage {
  private Map map = new HashMap();

  public ProblemPage() {
  map.put("en", "Hello");
  map.put("da", "Goddag");

  getSession().setLocale(new Locale("en", "EN"));

  add(new Link("enLocale")
  {
  public void onClick() {
  getSession().setLocale(new Locale("en", "EN"));
  }
  });
  add(new Link("daLocale")
  {
  public void onClick() {
  getSession().setLocale(new Locale("da", "DK"));
  }
  });

  Form outerform = new Form("outerform") {
  protected void onSubmit() {
  super.onSubmit();
  }
  };
  add(outerform);

  TextField txtField = new TextField("txtfield",new Model() {
  public Object getObject() {
  return map.get(getSession().getLocale().getLanguage());
  }

  public void setObject(Object o) {
  map.put(getSession().getLocale().getLanguage(), 
(String)o);

  }
  });
  outerform.add(txtField);

  Form innerform = new Form("innerform") {
  protected void onSubmit() {
  super.onSubmit();
  }
  };
  outerform.add(innerform);

  AjaxButton editButton= new AjaxButton("pressmeButton")
  {
  protected void onSubmit(AjaxRequestTarget target, Form form)
  {
  super.onSubmit();
  }
  };
  editButton.add(new SimpleAttributeModifier("value","Press me"));
//editButton.setDefaultFormProcessing(false);
  innerform.add(editButton);


  outerform.add(new AjaxButton("submitButton") {
  protected void onSubmit(AjaxRequestTarget target, Form form)
  {
  super.onSubmit();
  }
  });
  }
}








English
Danish


  

  
  
  

  








--
Kinds regards,
Morten Steffensen



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




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



Ajax Buttons and Form

2009-06-07 Thread Luther Baker
I'm saving a 'Post', like a blog post, and JPA's merge function doesn't
update the object in place but rather, returns an object reflecting the new
database fields (like "id" if it were set).

In my application, I'd like to manage insert / update by setting this new
'Post' as the model for my form. In this case, Updates have ids ... but the
following gives me grief since the Form is not typed. I can't cast to
IModel - so not sure of the right thing to do here. Thoughts?


Here is the form field:

final TextField *postId* = new TextField("id");
postId.setOutputMarkupId(true);
add(postId);


Here is my save handler:

@Override
protected void onSubmit(final AjaxRequestTarget target,
final Form form)
{
...
// works fine
post = (Post) form.getModelObject();
final Post postWithId = postService.save(post);
// works fine
final IModel newModel = new
CompoundPropertyModel(postWithId);

*// 1. I want to use this new 'Post' object but neither of these compile*
form.setModel(newModel);
form.setModelObject(postWithId);

ERROR: The method setModelObject(capture#6-of ?) in the type
Form is not applicable for the arguments (Post)



*2. This compiles fine but doesn't actually update the id field on screen:*

form.setDefaultModelObject(postWithId);
target.addComponent(*postId*);



*3. Or, instead resetting the model, I can manually set the id field on the
existing model - which is all I really want to accomplish in this case:
*
post = (Post) form.getModelObject();
final Post postWithId = postService.save(post);
post.setId(postWithId.getId());

feedbackPanel.add(new SimpleAttributeModifier("class",
"info"));
info(getString("m-successfully-saved"));

target.addComponent(feedbackPanel);
target.addComponent(postId);

This seems to work, updates the id on screen and causes subsequent JPA
'merge' invocations to update instead of insert. As you can see, being an
AJAX button, I did have to explicitly render the new id field .

So, is there a well-defined approach for this sort of thing?

1 - is there a way I can actually reset the model?
2 - when I reset the DefaultModelObject - the the id isn't rendering to
screen - which implies I don't know what the DefaultModelObject actually is.
3 - Is it appropriate to use the Form fields to help discern between updates
and inserts - or is there a more appropriate way to manage this within
Wicket that I'm missing. My next step is to HIDE the id on the screen - but
wanted to make sure that it was indeed a well-received way to even manage
this type of update.

Thanks,

-Luther


nested forms and locale

2009-06-07 Thread Morten Steffensen

Hi,
I am having problems using nested forms and changing locale.

I have 2 links for changing the locale. It works until i press the 
AjaxButton in the inner form. Hereafter the txtField's getObject is not 
called anymore.


What am i doing wrong ? Any suggestions ?



public class ProblemPage extends WebPage {
   private Map map = new HashMap();

   public ProblemPage() {
   map.put("en", "Hello");
   map.put("da", "Goddag");

   getSession().setLocale(new Locale("en", "EN"));

   add(new Link("enLocale")
   {
   public void onClick() {
   getSession().setLocale(new Locale("en", "EN"));
   }
   });
   add(new Link("daLocale")
   {
   public void onClick() {
   getSession().setLocale(new Locale("da", "DK"));
   }
   });

   Form outerform = new Form("outerform") {
   protected void onSubmit() {
   super.onSubmit();
   }
   };
   add(outerform);

   TextField txtField = new TextField("txtfield",new Model() {
   public Object getObject() {
   return map.get(getSession().getLocale().getLanguage());
   }

   public void setObject(Object o) {
   map.put(getSession().getLocale().getLanguage(),(String)o);
   }
   });
   outerform.add(txtField);

   Form innerform = new Form("innerform") {
   protected void onSubmit() {
   super.onSubmit();
   }
   };
   outerform.add(innerform);

   AjaxButton editButton= new AjaxButton("pressmeButton")
   {
   protected void onSubmit(AjaxRequestTarget target, Form form)
   {
   super.onSubmit();
   }
   };
   editButton.add(new SimpleAttributeModifier("value","Press me"));
//editButton.setDefaultFormProcessing(false);
   innerform.add(editButton);


   outerform.add(new AjaxButton("submitButton") {
   protected void onSubmit(AjaxRequestTarget target, Form form)
   {
   super.onSubmit();
   }
   });
   }
}








English
Danish


   

   
   
   

   








--
Kinds regards,
Morten Steffensen



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



users@wicket.apache.org

2009-06-07 Thread Stefan Lindner
Ah! Thank you! That's it!

-Ursprüngliche Nachricht-
Von: Johan Compagner [mailto:jcompag...@gmail.com] 
Gesendet: Sonntag, 7. Juni 2009 12:27
An: users@wicket.apache.org
Betreff: Re: Ajax URL encoding and &

ahh you write javascript yourself.

use:
 use JavascriptUtils.writeJavascript(*final* Response response,
*final*CharSequence text, String id) for that
That will make sure that the javascript is property escaped between CDATA



On Sun, Jun 7, 2009 at 01:51, Stefan Lindner  wrote:

> I want to trigger a method of a wicket component from  a self written
> JavaScript function e.g.
>
> 
>  onClickcall 'WicketAjax
> 
>
> So I create an AjaxBehavior that extends AbstractAjaxBehavior oder
> AbstractDefaultAjaxBehavior and add it to a Wicket Component.
>
> My class implements the onComponentRendered method jut like this
>
> String func = "function() { wicketAjaxGet('" + this.getCallbackUrl() +
> "'); }"
>
> RequestCycle tequestCycle = RequestCycle.get();
>
> Response response = tequestCycle.getResponse();
>
> response.write(builder.toScriptTag());
>
> And because getCallbackUrl does not escape the & the raw & is rendered into
> the page. This is nor problem for functionality (everything works well) but
> it makes html debugging hard because of the validation errors caused by &.
>
> Now I can do the encodeing by myself but then the wicketAjaxGet fires the
> respond method wit all parameters named "¶mName".
>
> Now I can call
>
> getComponent().getRequest().getParameter("¶mName")
>
> in the respond method but this looks strange for me.
>
> If this is the intended way to do such things I will do them so.
>
>
> 
>
> Von: Johan Compagner [mailto:jcompag...@gmail.com]
> Gesendet: So 07.06.2009 00:25
>  An: users@wicket.apache.org
> Betreff: Re: Ajax URL encoding and &
>
>
>
> ahh yes it is the ajax event behavior that is altered
> (thats an behavior that is attached to events so on attributes like
> onclick)
>
> which behavior do you exactly use and where is it exactly inserted in?
>
> On Sun, Jun 7, 2009 at 00:13, Stefan Lindner  wrote:
>
> > Looking into current trunk (1.4):
> > The only Class that extends AbstractAjaxBrhavior is
> > AbstractDefaultAjaxBehavior. In both classes the onComponentTag method
> does
> > nothingI should overwrite the onComponentTag method and escape all & to
> > &?
> > But when I do this, the ajax callback no longer works.
> >
> > 
> >
> > Von: Johan Compagner [mailto:jcompag...@gmail.com]
> > Gesendet: Sa 06.06.2009 23:28
> > An: users@wicket.apache.org
> > Betreff: Re: Ajax URL encoding and &
> >
> >
> >
> > This should be fixed in the current trunk i think
> >
> > yes getCallbackUrl doesnt escape the markup yet
> > But the onComponentTag of the AjaxBehaviors should escape it right before
> > it
> > gets inserted into the attributes markup.
> >
> >
> >
> > On Sat, Jun 6, 2009 at 20:34, Stefan Lindner 
> wrote:
> >
> > > In current wicket 1.4 trunk a call to
> > >
> > > AbstractAjaxBehavior.getCallbackUrl
> > >
> > > Returns something like
> > >
> > >
> > >
> wicketAjaxGet('?wicket:interface=:0:comp1:comp2::IActivePageBehaviorList
> > > ener:1:&wicket:ignoreIfNotActive=true'); };
> > >
> > > The Firefox html validator plugins don't accept this as correct urls.
> > > They tell me
> > >
> > > "cannot generate system identifier for general enttiy
> > > wicket:ignoreIfNotActive"
> > >
> > > And tell me to replace the "&" by "&" but this breaks
> > > wicketAjaxGet's functionality.
> > > Is there any trick to get this fixed (besides the option not to use
> > > strict html).
> > >
> > > Stefan.
> > >
> > > -
> > > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> > > For additional commands, e-mail: users-h...@wicket.apache.org
> > >
> > >
> >
> >
> >
> >
> >
> > -
> > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> > For additional commands, e-mail: users-h...@wicket.apache.org
> >
>
>
>
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>

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



Re: [Bug 1.3.6] Inconsistent RequestUtils.toAbsolutePath()

2009-06-07 Thread Johan Compagner
>
>
>
>
> a1 = http://foo.bar:8080/app/CurrentPage
> s1 = http://foo.bar:8080/app/CurrentPage
>
> a2 = http://foo.bar:8080/app/
> s2 = http://CurrentPage/ 
>
>
> a1 , s1 are correct ,
> a2 , s2 are totally wrong.
>



a1 , s1 en a2 are all correct.

but why s2 is a result when a2 is the input for that toAbsolutePath is
weird.
Because quickly looking at the code it should just doe a2 + relativePath to
the CurrentPage == s1...

Jus debug it once and go into that method

*

final
* StringBuffer result;

*if* (requestPath.endsWith("/"))

{

result =
*new* StringBuffer(requestPath);

}

*else*

{

// Remove everything after last slash (but not slash itself)

result =
*new* StringBuffer(requestPath.substring(0, requestPath.lastIndexOf('/') +
1));

}

thats the code and a1 goes into the else and a2 goes into the if.. But why
would that result in s2.


users@wicket.apache.org

2009-06-07 Thread Johan Compagner
ahh you write javascript yourself.

use:
 use JavascriptUtils.writeJavascript(*final* Response response,
*final*CharSequence text, String id) for that
That will make sure that the javascript is property escaped between CDATA



On Sun, Jun 7, 2009 at 01:51, Stefan Lindner  wrote:

> I want to trigger a method of a wicket component from  a self written
> JavaScript function e.g.
>
> 
>  onClickcall 'WicketAjax
> 
>
> So I create an AjaxBehavior that extends AbstractAjaxBehavior oder
> AbstractDefaultAjaxBehavior and add it to a Wicket Component.
>
> My class implements the onComponentRendered method jut like this
>
> String func = "function() { wicketAjaxGet('" + this.getCallbackUrl() +
> "'); }"
>
> RequestCycle tequestCycle = RequestCycle.get();
>
> Response response = tequestCycle.getResponse();
>
> response.write(builder.toScriptTag());
>
> And because getCallbackUrl does not escape the & the raw & is rendered into
> the page. This is nor problem for functionality (everything works well) but
> it makes html debugging hard because of the validation errors caused by &.
>
> Now I can do the encodeing by myself but then the wicketAjaxGet fires the
> respond method wit all parameters named "¶mName".
>
> Now I can call
>
> getComponent().getRequest().getParameter("¶mName")
>
> in the respond method but this looks strange for me.
>
> If this is the intended way to do such things I will do them so.
>
>
> 
>
> Von: Johan Compagner [mailto:jcompag...@gmail.com]
> Gesendet: So 07.06.2009 00:25
>  An: users@wicket.apache.org
> Betreff: Re: Ajax URL encoding and &
>
>
>
> ahh yes it is the ajax event behavior that is altered
> (thats an behavior that is attached to events so on attributes like
> onclick)
>
> which behavior do you exactly use and where is it exactly inserted in?
>
> On Sun, Jun 7, 2009 at 00:13, Stefan Lindner  wrote:
>
> > Looking into current trunk (1.4):
> > The only Class that extends AbstractAjaxBrhavior is
> > AbstractDefaultAjaxBehavior. In both classes the onComponentTag method
> does
> > nothingI should overwrite the onComponentTag method and escape all & to
> > &?
> > But when I do this, the ajax callback no longer works.
> >
> > 
> >
> > Von: Johan Compagner [mailto:jcompag...@gmail.com]
> > Gesendet: Sa 06.06.2009 23:28
> > An: users@wicket.apache.org
> > Betreff: Re: Ajax URL encoding and &
> >
> >
> >
> > This should be fixed in the current trunk i think
> >
> > yes getCallbackUrl doesnt escape the markup yet
> > But the onComponentTag of the AjaxBehaviors should escape it right before
> > it
> > gets inserted into the attributes markup.
> >
> >
> >
> > On Sat, Jun 6, 2009 at 20:34, Stefan Lindner 
> wrote:
> >
> > > In current wicket 1.4 trunk a call to
> > >
> > > AbstractAjaxBehavior.getCallbackUrl
> > >
> > > Returns something like
> > >
> > >
> > >
> wicketAjaxGet('?wicket:interface=:0:comp1:comp2::IActivePageBehaviorList
> > > ener:1:&wicket:ignoreIfNotActive=true'); };
> > >
> > > The Firefox html validator plugins don't accept this as correct urls.
> > > They tell me
> > >
> > > "cannot generate system identifier for general enttiy
> > > wicket:ignoreIfNotActive"
> > >
> > > And tell me to replace the "&" by "&" but this breaks
> > > wicketAjaxGet's functionality.
> > > Is there any trick to get this fixed (besides the option not to use
> > > strict html).
> > >
> > > Stefan.
> > >
> > > -
> > > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> > > For additional commands, e-mail: users-h...@wicket.apache.org
> > >
> > >
> >
> >
> >
> >
> >
> > -
> > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> > For additional commands, e-mail: users-h...@wicket.apache.org
> >
>
>
>
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>


Re: WWB for W 1.4 (was Re: when will be wicket 1.4 final release)

2009-06-07 Thread danisevsky
Hi Daniel, WWB works great, thank you very much.

2009/6/6 Daniel Toffetti 

> danisevsky  gmail.com> writes:
> >
> > Hi Daniel, when I tried build web beans project I get the following error
> >
> > [ERROR] BUILD FAILURE
> > [INFO]
> > 
> > [INFO] Compilation failure
> >
> > C:\projects\webbeans\wicketwebbeans-databinder\src\main\java\com\
> googlecode\wick
> > etwebbeans\databinder\DataSearchFilter.java:[91,23] cannot find symbol
> > symbol  : method getModelObject()
> > location: class net.databinder.components.hib.SearchPanel
> >
> > C:\projects\webbeans\wicketwebbeans-databinder\src\main\java\com\
> googlecode\wick
> > etwebbeans\databinder\DataSearchFilter.java:[101,59] cannot find symbol
> > symbol  : method getModelObject()
> > location: class net.databinder.components.hib.SearchPanel
> >
>
> Hi,
>
>Databinder support is not migrated to 1.4 yet, and if I'm correct
> Databinder itself is not migrated to 1.4, try building the WWB jar
> and not the parent project, I'll take a look at Databinder status.
>
> hth,
>
> Daniel
>
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Re: [Bug 1.3.6] Inconsistent RequestUtils.toAbsolutePath()

2009-06-07 Thread smallufo
2009/6/7 Johan Compagner 

> can you debug and see what this returns for both situations?
>
>
> ((WebRequest)RequestCycle.*get*().getRequest()).getHttpServletRequest()
> .getRequestURL().toString()
>


ok , here is my test :

String a1 =
((WebRequest)RequestCycle.get().getRequest()).getHttpServletRequest().getRequestURL().toString();
System.out.println("a1 = " + a1);

String s1 =
RequestUtils.toAbsolutePath(getRequestCycle().urlFor(CurrentPage.class ,
pps).toString());
System.out.println("s1 = " + s1);

Link link = new AjaxFallbackLink("link")
{
  @Override
  public void onClick(AjaxRequestTarget target)
  {
String a2 =
((WebRequest)RequestCycle.get().getRequest()).getHttpServletRequest().getRequestURL().toString();
System.out.println("a2 = " + a2);

final String s2 =
RequestUtils.toAbsolutePath(getRequestCycle().urlFor(CurrentPage.class ,
pps).toString());
System.out.println("s2 = " + s2);
  }
};


a1 = http://foo.bar:8080/app/CurrentPage
s1 = http://foo.bar:8080/app/CurrentPage

a2 = http://foo.bar:8080/app/
s2 = http://CurrentPage/


a1 , s1 are correct ,
a2 , s2 are totally wrong.