Re: How to close a ModalWindow without AjaxRequestTarget

2015-04-20 Thread Martin Grigorov
Hi,

It is not clear why you have two submit buttons in HTML.
I think you need just one - AjaxButton.
It will submit the form via Ajax and if errors occur then its
#onError(AjaxRequestTarget) will be called.
If everything is OK then #onSubmit() will be called.
In both cases you have AjaxRequestTarget around to close the ModalWindow.

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Tue, Apr 21, 2015 at 9:09 AM, Ulrich  wrote:

> I have already  asked this question
> <
> http://apache-wicket.1842946.n4.nabble.com/Modal-panel-reloaded-when-selecting-from-DropDownChoice-td4670394.html
> >
> but maybe it was off topic there.
>
> The Modal Window provides the method #close(AjaxRequestTarget). But I want
> to provide a Button to validate entered data and display a message in case
> of error otherwise close.
> If I use AjaxSubmitButton() to handle the button the message is not part of
> the target and not updated. I I use Link() the message becomes updated but
> I
> have no means to close the window.
> HTML:
>
>
> Java:
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/How-to-close-a-ModalWindow-without-AjaxRequestTarget-tp4670429.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


How to close a ModalWindow without AjaxRequestTarget

2015-04-20 Thread Ulrich
I have already  asked this question

  
but maybe it was off topic there.

The Modal Window provides the method #close(AjaxRequestTarget). But I want
to provide a Button to validate entered data and display a message in case
of error otherwise close.
If I use AjaxSubmitButton() to handle the button the message is not part of
the target and not updated. I I use Link() the message becomes updated but I
have no means to close the window.
HTML:


Java:



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/How-to-close-a-ModalWindow-without-AjaxRequestTarget-tp4670429.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: AjaxLazyLoadPanel

2015-04-20 Thread Andrew Geery
In AjaxLazyLoadPanel#getLazyComponent(String), you should be using the id
parameter, not "pList", when creating the PListPanel.

Andrew

@Override
public Component getLazyLoadComponent(String id) {
return new PListPanel("pList", pModel); // change
the first param from "pList" to id
}

On Mon, Apr 20, 2015 at 11:10 PM, Chris  wrote:

> Hi all,
>
> I am following the example from
> http://www.mkyong.com/wicket/how-do-use-ajaxlazyloadpanel-in-wicket/ but
> get following error:
>
> Last cause: Cannot replace a component which has not been added:
> id='pList', component=[PListPanel [Component id = pList]]:
> [AjaxLazyLoadPanel [Component id = pList]]
>
> By the way, is the checking for JavaEnabled valid or still needed? I have
> JavaScript enabled but the method #isJavaEnabled returns false;
>
> WebClientInfo clientInfo = WebSession.get().getClientInfo();
> if (clientInfo.getProperties().isJavaEnabled()) {
> add(new AjaxLazyLoadPanel("pList", pModel) {
> @Override
> public Component getLazyLoadComponent(String id) {
> return new PListPanel("pList", pModel);
> }
> }).setOutputMarkupId(true);
> } else {
> add(new PListPanel("pList", pModel);
> }
>
> Thanks, Chris


AjaxLazyLoadPanel

2015-04-20 Thread Chris
Hi all,

I am following the example from 
http://www.mkyong.com/wicket/how-do-use-ajaxlazyloadpanel-in-wicket/ but get 
following error:

Last cause: Cannot replace a component which has not been added: id='pList', 
component=[PListPanel [Component id = pList]]:
[AjaxLazyLoadPanel [Component id = pList]]

By the way, is the checking for JavaEnabled valid or still needed? I have 
JavaScript enabled but the method #isJavaEnabled returns false;

WebClientInfo clientInfo = WebSession.get().getClientInfo();
if (clientInfo.getProperties().isJavaEnabled()) {
add(new AjaxLazyLoadPanel("pList", pModel) {
@Override
public Component getLazyLoadComponent(String id) {
return new PListPanel("pList", pModel);
}
}).setOutputMarkupId(true);
} else {
add(new PListPanel("pList", pModel);
}

Thanks, Chris

Remove 'wicket' in URL

2015-04-20 Thread Chris
Hi all,

I would like to delete the context ‚wicket‘ in the URL but do not like to set 
another one (e.g. wicket/page?2 should become /page?2.
How is this possible?

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



Re: Radio group add ajax behavior

2015-04-20 Thread Chris
Ok, I have fixed it by setting the id for the list items and adapting the 
callback function to select by id and then by name.

Chris


> Am 20.04.2015 um 21:53 schrieb Chris :
> 
> Hi Sven,
> 
> I have put the radio group in a list of items. Basically it works so when I 
> click on a radio button the corresponding item is called.
> However, when clicking the cancel button, always the radio group of the first 
> item in the list is called. How can the callback function 
> ($('input[name=\"%s\"]')[0];) be bound to the items so not the first input 
> field in the DOM tree is called?
> The id of the items is given by Wicket...
> 
> Thanks Chris
> 
> 
> 
>> Am 20.04.2015 um 03:35 schrieb Chris :
>> 
>> Perfect - thanks a lot for the hint!
>> 
>> best regards, Chris
>> 
>>> Am 19.04.2015 um 22:43 schrieb Sven Meier :
>>> 
>>> Hi Christ,
>>> 
>>> for AjaxFormChoiceComponentUpdatingBehavior it is important that the click 
>>> happens on one of the "radio" elements.
>>> If the selection is cancalled, we can just use the first radio:
>>> 
>>>  String name = formComponent.getInputName();
>>> 
>>> response.render(OnDomReadyHeaderItem.forScript(String.format("$('input[name=\"%s\"]').rating({
>>>  callback: function(value, link) { var option = this; if (value == 
>>> undefined) { option = $('input[name=\"%s\"]')[0]; } 
>>> $(option).trigger('click'); }});", name, name)));
>>> 
>>> Note that I had to remove a 'workaround' from the plugin's soure to make 
>>> this work (line 181 ff):
>>> 
>>>  // backward compatibility, form element to plugin
>>> //input.on('change.rating',function(event){
>>> //if(event.selfTriggered) return false;
>>> //$(this).rating('select');
>>> //});
>>> 
>>> I don't understand what that is for - but that isn't a Wicket question ;).
>>> 
>>> Regards
>>> Sven
>>> 
>>> 
>>> On 19.04.2015 20:46, Chris wrote:
 Hi Sven & all,
 
 I would also like to get a callback for the cancel button.
 
 I tried following adjustment, but in this case the 
 #onUpdate(AjaxRequestTarget target) method is called multiple times and in 
 the end, all stars are colored/enabled (instead of all stars greyed out).
 
 response.render(OnDomReadyHeaderItem.forScript(String.format("$('%s').rating({
  callback: function(value, link) {  if (typeof $(this).attr('id') == 
 'undefined') {$('%s').trigger('click');} else {$(this).trigger('click');} 
 }});", selector, selector)));
 
 When the cancel rating link is clicked the id is undefined. I cannot make 
 a JS click event on this div, maybe as it is added later via the JS?
 http://stackoverflow.com/questions/1551102/jquery-star-rating-plugin-and-cancel-rating-button
  
 
 
 thanks a lot,
 Chris
 
 
 
 
> Am 19.04.2015 um 15:26 schrieb Chris :
> 
> Sven, you are great!
> 
> Your solution works perfect.
> 
> Thanks a lot for your help!!
> Chris
> 
>> Am 19.04.2015 um 11:55 schrieb Sven Meier :
>> 
>> Hi Chris,
>> 
>> I've opened a pull request.
>> 
>> Hope this helps
>> Sven
>> 
>> 
>> On 19.04.2015 02:43, Chris wrote:
>>> Hi Sven & all,
>>> 
>>> when using the JS Star Rating plugin 
>>> (https://www.fyneworks.com/jquery/star-rating 
>>> , star images instead of 
>>> radio boxes), the #AjaxFormChoicecomponentUpdatingBehaviour does not 
>>> work anymore.
>>> 
>>> I have created a sample project based on the wicket-example 
>>> „RadioGroupPage“ and put it here: https://github.com/cat1000/StarRating 
>>> 
>>> 
>>> It would be great if someone could have a look the conflict.
>>> 
>>> Thanks a lot,
>>> Chris
>>> 
>>> 
>>> 
>>> 
>>> 
 Am 18.04.2015 um 23:43 schrieb Chris :
 
 Hi Sven,
 
 have you added the AjaxFormChoicecomponentUpdatingBehaviour in this 
 example to the group?
 
 group.add(new AjaxFormChoiceComponentUpdatingBehavior() {
 protected void onUpdate(AjaxRequestTarget target) {
 // Ajax actions here
 System.out.println("The selected value is " + 
 getComponent().getDefaultModelObjectAsString());
 }
 });
 
 Thanks, Chris
 
> Am 18.04.2015 um 13:24 schrieb Sven Meier :
> 
> Looks good.
> 
> I've just added an AjaxFormChoiceComponentUpdatingBehavior to 
> wicket-examples' RadioGroupPage and it worked as expected.
> 
> Which Wicket version? Can you create a quickstart?
> 
> Have fun
> Sven
> 
> On 18.04.2015 

Re: Radio group add ajax behavior

2015-04-20 Thread Chris
Hi Sven,

I have put the radio group in a list of items. Basically it works so when I 
click on a radio button the corresponding item is called.
However, when clicking the cancel button, always the radio group of the first 
item in the list is called. How can the callback function 
($('input[name=\"%s\"]')[0];) be bound to the items so not the first input 
field in the DOM tree is called?
The id of the items is given by Wicket...

Thanks Chris



> Am 20.04.2015 um 03:35 schrieb Chris :
> 
> Perfect - thanks a lot for the hint!
> 
> best regards, Chris
> 
>> Am 19.04.2015 um 22:43 schrieb Sven Meier :
>> 
>> Hi Christ,
>> 
>> for AjaxFormChoiceComponentUpdatingBehavior it is important that the click 
>> happens on one of the "radio" elements.
>> If the selection is cancalled, we can just use the first radio:
>> 
>>   String name = formComponent.getInputName();
>> 
>> response.render(OnDomReadyHeaderItem.forScript(String.format("$('input[name=\"%s\"]').rating({
>>  callback: function(value, link) { var option = this; if (value == 
>> undefined) { option = $('input[name=\"%s\"]')[0]; } 
>> $(option).trigger('click'); }});", name, name)));
>> 
>> Note that I had to remove a 'workaround' from the plugin's soure to make 
>> this work (line 181 ff):
>> 
>>   // backward compatibility, form element to plugin
>> //input.on('change.rating',function(event){
>> //if(event.selfTriggered) return false;
>> //$(this).rating('select');
>> //});
>> 
>> I don't understand what that is for - but that isn't a Wicket question ;).
>> 
>> Regards
>> Sven
>> 
>> 
>> On 19.04.2015 20:46, Chris wrote:
>>> Hi Sven & all,
>>> 
>>> I would also like to get a callback for the cancel button.
>>> 
>>> I tried following adjustment, but in this case the 
>>> #onUpdate(AjaxRequestTarget target) method is called multiple times and in 
>>> the end, all stars are colored/enabled (instead of all stars greyed out).
>>> 
>>> response.render(OnDomReadyHeaderItem.forScript(String.format("$('%s').rating({
>>>  callback: function(value, link) {  if (typeof $(this).attr('id') == 
>>> 'undefined') {$('%s').trigger('click');} else {$(this).trigger('click');} 
>>> }});", selector, selector)));
>>> 
>>> When the cancel rating link is clicked the id is undefined. I cannot make a 
>>> JS click event on this div, maybe as it is added later via the JS?
>>> http://stackoverflow.com/questions/1551102/jquery-star-rating-plugin-and-cancel-rating-button
>>>  
>>> 
>>> 
>>> thanks a lot,
>>> Chris
>>> 
>>> 
>>> 
>>> 
 Am 19.04.2015 um 15:26 schrieb Chris :
 
 Sven, you are great!
 
 Your solution works perfect.
 
 Thanks a lot for your help!!
 Chris
 
> Am 19.04.2015 um 11:55 schrieb Sven Meier :
> 
> Hi Chris,
> 
> I've opened a pull request.
> 
> Hope this helps
> Sven
> 
> 
> On 19.04.2015 02:43, Chris wrote:
>> Hi Sven & all,
>> 
>> when using the JS Star Rating plugin 
>> (https://www.fyneworks.com/jquery/star-rating 
>> , star images instead of 
>> radio boxes), the #AjaxFormChoicecomponentUpdatingBehaviour does not 
>> work anymore.
>> 
>> I have created a sample project based on the wicket-example 
>> „RadioGroupPage“ and put it here: https://github.com/cat1000/StarRating 
>> 
>> 
>> It would be great if someone could have a look the conflict.
>> 
>> Thanks a lot,
>> Chris
>> 
>> 
>> 
>> 
>> 
>>> Am 18.04.2015 um 23:43 schrieb Chris :
>>> 
>>> Hi Sven,
>>> 
>>> have you added the AjaxFormChoicecomponentUpdatingBehaviour in this 
>>> example to the group?
>>> 
>>> group.add(new AjaxFormChoiceComponentUpdatingBehavior() {
>>>  protected void onUpdate(AjaxRequestTarget target) {
>>>  // Ajax actions here
>>>  System.out.println("The selected value is " + 
>>> getComponent().getDefaultModelObjectAsString());
>>>  }
>>> });
>>> 
>>> Thanks, Chris
>>> 
 Am 18.04.2015 um 13:24 schrieb Sven Meier :
 
 Looks good.
 
 I've just added an AjaxFormChoiceComponentUpdatingBehavior to 
 wicket-examples' RadioGroupPage and it worked as expected.
 
 Which Wicket version? Can you create a quickstart?
 
 Have fun
 Sven
 
 On 18.04.2015 13:19, Chris wrote:
> The html is as follows:
> 
> 
>  
> 
>
> 
>...
> 
>  
> 
> 
> best regards, Chris
> 
> 
>> Am 18.04.2015 um 13:14 schrieb Chris :
>> 

Re: Map panel - javascript

2015-04-20 Thread Chris
I found the solution: I had to call the method invalidateSize(); on the map.

best regards, Chris


> Am 20.04.2015 um 18:02 schrieb Chris :
> 
> I have created a quickstart project: https://github.com/cat1000/Map
> 
> Thanks, Chris
> 
> 
>> Am 20.04.2015 um 17:12 schrieb Chris :
>> 
>> PS: the map is generated using the Leaflet JS library 
>> 
>> 
>> 
>>> Am 20.04.2015 um 16:51 schrieb Chris :
>>> 
>>> Hi all,
>>> 
>>> I have a map panel whose height is dynamically calculated as it should 
>>> always go till the bottom of the page and above, other elements have set a 
>>> dynamic height.
>>> I am calculating the height with JS (i.e.  
>>> $('#map').height(Math.round($(window).height() - variable));) and call the 
>>> JS function via 
>>> response.render(OnDomReadyHeaderItem.forScript("calcHeight();"));
>>> 
>>> The problem is that the height of the layer (see grey area) is right, but 
>>> the overlay’s height is wrong. See http://pasteboard.co/2HYMXcRA.png 
>>> 
>>> It seems that the dynamically calculated height is not taken into account 
>>> for the overlay. (when declaring the height in CSS it works without 
>>> problems).
>>> 
>>> Would it help to generate the script below as well in Wicket/Java and put 
>>> it in the response via #OnDomReadyHeaderItem? But how to put it right in 
>>> the DIV element of the panel then?
>>> 
>>> The map panel looks like this:
>>> 
>>> 
>>>  
>>>  
>>> // create a map in the "map" div, set the view to a given place and zoom
>>> var map = L.map('map').setView([51.505, -0.09], 13);
>>> 
>>> // add an OpenStreetMap tile layer
>>> L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
>>>  attribution: '© http://osm.org/copyright";>OpenStreetMap 
>>> contributors'
>>> }).addTo(map);
>>> 
>>> // add a marker in the given location, attach some popup content to it and 
>>> open the popup
>>> L.marker([51.5, -0.09]).addTo(map)
>>>  .bindPopup('A pretty CSS3 popup. 
Easily customizable.') >>> .openPopup(); >>> >>> >>> >>> Thanks a lot, >>> Chris >>> >>> >>> >> >> >> - >> 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: A few questions - upgrading from 1.5 to 6.19

2015-04-20 Thread Christopher Merrill
It is not even getting that far :(  Breakpoint on line 603 is never
hit...nor is a breakpoint on line 554, for that matter. I was starting to
suspect something was up with the Dev Tools in my browser(s), until I
successfully stopped at a breakpoint in some example scripts.



On Fri, Apr 17, 2015 at 5:16 PM, Martin Grigorov 
wrote:

> Then most probably some precondition stops the Ajax call from firing.
> Put a breakpoint at
>
> https://github.com/apache/wicket/blob/e07475cf989565bad53fd8dfcd5d109912ae6bef/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js#L603
> and see what happens.
>
> Martin Grigorov
> Wicket Training and Consulting
> https://twitter.com/mtgrigorov
>
> On Sat, Apr 18, 2015 at 12:08 AM, Christopher Merrill <
> ch...@webperformance.com> wrote:
>
> > Oh...uhhh...yeah. Gee, if I wasn't working on 3 things at once, I might
> > have thought of that!  I wish there was a user group that could help with
> > _that_ problem :)
> >
> >
> > So no, there is no traffic reported from either Chrome or Firefox network
> > tabs after the initial page load. I tried with multiple different Ajax
> > controls - they all exhibit the same behavior.
> >
> >
> > So when we upgraded from 1.5 to 6.19, I just grabbed the latest versions
> of
> > the JARs we already had in our build. We have a very manual build system
> > (working on moving toward something with dependency management...maybe
> > Gradle), so if there are new module dependencies beyond those obvious in
> > the dependencies listed at mavenrepository, for example, I might be
> missing
> > those. Could that be the cause?
> >
> > Here's what we have:
> > joda-time-2.0.jar
> > wicket-auth-roles-6.19.0.jar
> > wicket-core-6.19.0.jar
> > wicket-datetime-6.19.0.jar
> > wicket-extensions-6.19.0.jar
> > wicket-ioc-6.19.0.jar
> > wicket-request-6.19.0.jar
> > wicket-spring-6.19.0.jar
> > wicket-util-6.19.0.jar
> > wicketstuff-gae-initializer-6.19.0.jar
> > wicketstuff-progressbar-6.19.0.jar
> >
> > TIA!
> > Chris
> >
> >
> >
> > On Fri, Apr 17, 2015 at 4:48 PM, Martin Grigorov 
> > wrote:
> >
> > > Use the browser's Dev Tools > Network tab.
> > >
> > > Martin Grigorov
> > > Wicket Training and Consulting
> > > https://twitter.com/mtgrigorov
> > >
> > > On Fri, Apr 17, 2015 at 11:42 PM, Christopher Merrill <
> > > ch...@webperformance.com> wrote:
> > >
> > > > The "wicket ajax debug" window reports nothing when I click Ajax
> links
> > in
> > > > either Chrome or Firefox. Is there somewhere else I should look for
> an
> > > > indication of Ajax activity - somewhere in Wicket to set a breakpoint
> > or
> > > > logging to enable?
> > > >
> > > > BTW, That window is acting a little flakey for me - the move and
> resize
> > > > don't work. Is that normal? If not, possibly related?
> > > >
> > > > TIA!
> > > > Chris
> > > >
> > > >
> > > > On Fri, Apr 17, 2015 at 4:27 PM, Martin Grigorov <
> mgrigo...@apache.org
> > >
> > > > wrote:
> > > >
> > > > > Hi,
> > > > >
> > > > > Check whether the browser makes an Ajax request to the server when
> > you
> > > > > click the link.
> > > > >
> > > > > Martin Grigorov
> > > > > Wicket Training and Consulting
> > > > > https://twitter.com/mtgrigorov
> > > > >
> > > > > On Fri, Apr 17, 2015 at 11:20 PM, Christopher Merrill <
> > > > > ch...@webperformance.com> wrote:
> > > > >
> > > > > > Thanks, Sven.  I read that and I _think_ I understand it.  I
> looked
> > > > back
> > > > > at
> > > > > > the source and found:
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> Wicket.Ajax.ajax({"u":"./OrganizationAdministration?7-1.IBehaviorListener.0-form-create_customer_link","e":"click","c":"create__customer__link5","i":"create__customer__link5--ajax-indicator"});;
> > > > > >
> > > > > > which seems to be registering a listener. But that doesn't tell
> me
> > > why
> > > > my
> > > > > > onClick() code is not called.
> > > > > >
> > > > > > This part of the article you linked:
> > > > > >   "The good news is the client APIs are mostly the same and the
> > > > > application
> > > > > > developers will not need to change their applications."
> > > > > > seems to be indicating that I should not have to change my code -
> > as
> > > > the
> > > > > > IndicatingAjaxLink component (a wicket extension) or the AjaxLink
> > > > should
> > > > > be
> > > > > > handling that. Am I wrong?
> > > > > >
> > > > > > This page seems to indicate overriding onClick() for an AjaxLink
> is
> > > > still
> > > > > > the way to go:
> > > > > >   https://wicket.apache.org/guide/guide/ajax.html
> > > > > >
> > > > > > I feel like I'm missing something...
> > > > > >
> > > > > > Chris
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > On Thu, Apr 16, 2015 at 3:59 PM, Sven Meier 
> > wrote:
> > > > > >
> > > > > > > Hi,
> > > > > > >
> > > > > > >  #2 is with an IndicatingAjaxLink.
> > > > > > >> But the generated HTML has a bad href and no onClick():
> > > > > > >>
> > > > > > >
> > > > > > > Wicket 

Re: Map panel - javascript

2015-04-20 Thread Chris
I have created a quickstart project: https://github.com/cat1000/Map

Thanks, Chris


> Am 20.04.2015 um 17:12 schrieb Chris :
> 
> PS: the map is generated using the Leaflet JS library 
> 
> 
> 
>> Am 20.04.2015 um 16:51 schrieb Chris :
>> 
>> Hi all,
>> 
>> I have a map panel whose height is dynamically calculated as it should 
>> always go till the bottom of the page and above, other elements have set a 
>> dynamic height.
>> I am calculating the height with JS (i.e.  
>> $('#map').height(Math.round($(window).height() - variable));) and call the 
>> JS function via 
>> response.render(OnDomReadyHeaderItem.forScript("calcHeight();"));
>> 
>> The problem is that the height of the layer (see grey area) is right, but 
>> the overlay’s height is wrong. See http://pasteboard.co/2HYMXcRA.png 
>> 
>> It seems that the dynamically calculated height is not taken into account 
>> for the overlay. (when declaring the height in CSS it works without 
>> problems).
>> 
>> Would it help to generate the script below as well in Wicket/Java and put it 
>> in the response via #OnDomReadyHeaderItem? But how to put it right in the 
>> DIV element of the panel then?
>> 
>> The map panel looks like this:
>> 
>> 
>>   
>>   
>> // create a map in the "map" div, set the view to a given place and zoom
>> var map = L.map('map').setView([51.505, -0.09], 13);
>> 
>> // add an OpenStreetMap tile layer
>> L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
>>   attribution: '© http://osm.org/copyright";>OpenStreetMap 
>> contributors'
>> }).addTo(map);
>> 
>> // add a marker in the given location, attach some popup content to it and 
>> open the popup
>> L.marker([51.5, -0.09]).addTo(map)
>>   .bindPopup('A pretty CSS3 popup. 
Easily customizable.') >> .openPopup(); >> >> >> >> Thanks a lot, >> Chris >> >> >> > > > - > 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: Map panel - javascript

2015-04-20 Thread Chris
PS: the map is generated using the Leaflet JS library 



> Am 20.04.2015 um 16:51 schrieb Chris :
> 
> Hi all,
> 
> I have a map panel whose height is dynamically calculated as it should always 
> go till the bottom of the page and above, other elements have set a dynamic 
> height.
> I am calculating the height with JS (i.e.  
> $('#map').height(Math.round($(window).height() - variable));) and call the JS 
> function via response.render(OnDomReadyHeaderItem.forScript("calcHeight();"));
> 
> The problem is that the height of the layer (see grey area) is right, but the 
> overlay’s height is wrong. See http://pasteboard.co/2HYMXcRA.png 
> 
> It seems that the dynamically calculated height is not taken into account for 
> the overlay. (when declaring the height in CSS it works without problems).
> 
> Would it help to generate the script below as well in Wicket/Java and put it 
> in the response via #OnDomReadyHeaderItem? But how to put it right in the DIV 
> element of the panel then?
> 
> The map panel looks like this:
> 
> 
>
>
> // create a map in the "map" div, set the view to a given place and zoom
> var map = L.map('map').setView([51.505, -0.09], 13);
> 
> // add an OpenStreetMap tile layer
> L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
>attribution: '© http://osm.org/copyright";>OpenStreetMap 
> contributors'
> }).addTo(map);
> 
> // add a marker in the given location, attach some popup content to it and 
> open the popup
> L.marker([51.5, -0.09]).addTo(map)
>.bindPopup('A pretty CSS3 popup. 
Easily customizable.') >.openPopup(); > > > > Thanks a lot, > Chris > > > - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org

Map panel - javascript

2015-04-20 Thread Chris
Hi all,

I have a map panel whose height is dynamically calculated as it should always 
go till the bottom of the page and above, other elements have set a dynamic 
height.
I am calculating the height with JS (i.e.  
$('#map').height(Math.round($(window).height() - variable));) and call the JS 
function via response.render(OnDomReadyHeaderItem.forScript("calcHeight();"));

The problem is that the height of the layer (see grey area) is right, but the 
overlay’s height is wrong. See http://pasteboard.co/2HYMXcRA.png 

It seems that the dynamically calculated height is not taken into account for 
the overlay. (when declaring the height in CSS it works without problems).

Would it help to generate the script below as well in Wicket/Java and put it in 
the response via #OnDomReadyHeaderItem? But how to put it right in the DIV 
element of the panel then?

The map panel looks like this:




// create a map in the "map" div, set the view to a given place and zoom
var map = L.map('map').setView([51.505, -0.09], 13);

// add an OpenStreetMap tile layer
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '© http://osm.org/copyright";>OpenStreetMap 
contributors'
}).addTo(map);

// add a marker in the given location, attach some popup content to it and open 
the popup
L.marker([51.5, -0.09]).addTo(map)
.bindPopup('A pretty CSS3 popup. 
Easily customizable.') .openPopup(); Thanks a lot, Chris

Re: Paypal Integration in wicket

2015-04-20 Thread vp143
Hi jayeshps,

I have implemented PayPal IPN in the following way:

In the html form you submit, you set the notifyUrl to a path i.e.
www.example.com/payment/ipn

In my Application class I have the following: mountPage("/payment/ipn",
IPNPaymentHandler.class);

Then my IPNPaymentHandler.class is as follows:

public class IPNPaymentHandler extends WebPage {
private static final Log log =
LogFactory.getLog(IPNPaymentHandler.class);
public IPNPaymentHandler() {
super();
log.debug("IPN Payment being received");
Request request = getRequest();

try {
Set paramSet =
request.getRequestParameters().getParameterNames();
Iterator iterator = paramSet.iterator();

StringBuffer sb = new StringBuffer();
sb.append("cmd=_notify-validate");
while(iterator.hasNext()){
String paramName = (String)iterator.next();
String paramValue =
request.getRequestParameters().getParameterValue(paramName).toString();
sb.append("&" + paramName + "=" + 
URLEncoder.encode(paramValue,
"UTF-8"));
}

URL u = new 
URL(AppUtil.getSettings().getPayPalWebsiteStandardUrl());
URLConnection uc = u.openConnection();
uc.setDoOutput(true);

uc.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
PrintWriter pw = new PrintWriter(uc.getOutputStream());
pw.println(sb.toString());
pw.close();

BufferedReader in = new BufferedReader(new
InputStreamReader(uc.getInputStream()));
String res = in.readLine();
in.close();

// assign posted variables to local variables
String itemName =
request.getRequestParameters().getParameterValue("item_name").toString();
String itemNumber =
request.getRequestParameters().getParameterValue("item_number").toString();
String paymentStatus =
request.getRequestParameters().getParameterValue("payment_status").toString();
String paymentAmount =
request.getRequestParameters().getParameterValue("mc_gross").toString();
String paymentCurrency =
request.getRequestParameters().getParameterValue("mc_currency").toString();
String txnId =
request.getRequestParameters().getParameterValue("txn_id").toString();
String receiverEmail =
request.getRequestParameters().getParameterValue("receiver_email").toString();
String payerEmail =
request.getRequestParameters().getParameterValue("payer_email").toString();

//check notification validation
if(res != null && res.equals("VERIFIED")) {
if(paymentStatus.equals("Completed")) {
//Do business logic
}
else {
log.debug("paymentStatus = " + 
paymentStatus);
}
}
else if(res != null && res.equals("INVALID")) {
log.info("result = " + res);
log.info("itemName = " + itemName + " 
itemNumber = " + itemNumber + "
paymentStatus = " + paymentStatus + " paymentAmount = " + paymentAmount + "
" + paymentCurrency);
log.info(" txnId = " + txnId + " receiverEmail 
= " + receiverEmail + "
payerEmail = " + payerEmail);
}
else {
log.info("result = " + res);
log.info("itemName = " + itemName + " 
itemNumber = " + itemNumber + "
paymentStatus = " + paymentStatus + " paymentAmount = " + paymentAmount + "
" + paymentCurrency);
log.info(" txnId = " + txnId + " receiverEmail 
= " + receiverEmail + "
payerEmail = " + payerEmail);
}
}
catch(MalformedURLException mue) {
mue.printStackTrace();
}
catch(IOException ioe) {
ioe.printStackTrace();
}
}

}

The above is just the skeleton where you can fine tune to your needs... 
Please do let me know if you see any flaws payment needs to be done
right especially with security etc.

Regards
Vishal

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Paypal-Integration-in-wicket-tp4670325p4670415.html

Re: Paypal Integration in wicket

2015-04-20 Thread lucast
Hi Jayeshps,
I have implemented a wicket pay with paypal button a few weeks ago.

The beauty of working with wicket is that you do not have to hard-code and
hide the html parameters you pass to paypal on your html.
It can all be done on the AjaxButton.onSubmit();

I am assuming you're familiar with the parameter's passed to paypal, if not,
here is a good example:
http://www.onlineinteract.com/wiki/viewpage.php?pageId=179
  

Also, an explanation of each parameter can be  found here

 
.


Ok, onto the code:

Inside the AjaxButton.onSubmit() button, you need to construct the URL with
parameters to pass to paypal:
An example url is this:
https://www.paypal.com/cgi-bin/webscr?cmd=_cart&upload=1&no_shipping=1&no_note=1&custom=0A566EC9F6AC27E9¤cy_code=GBP&lc=GB&bn=business_BuyNow_WPS_GB&return=https://localhost:8443/paymentpage/sucessParameters&cancel_return=https://localhost:8443/paymentpage/cancelParameters¬ify_url=https://localhost:8443/paypalipnprocess&business=ad...@businessowner.com&item_name_1=entry_test_test&item_number_1=DB3BE2BD0BFC8D03&amount_1=0.30


Notice how all parameters are separated by '&'. 

You can produce the above URL from the server side, avoiding posting all of
the above info in hidden fields on the HTML form post parameters. 

The way I have implemented is as follow:
AjaxButton.onSubmit() 
{
   setResponsePage(new PayPalPaymentGatewayExampleClass(parameters to
construct the url));
}


I've attached the PayPalPaymentGatewayExampleClass which extends
RedirectPage2 on this post.
PayPalPaymentGatewayExampleClass.java

  
RedirectPage2.html
  
RedirectPage2.java
  

PayPalPaymentGatewayExampleClass builds the URL with the necessary
parameters before posting the request to Paypal.


Notice that on RedirectPage2 I throw new RedirectToUrlException(
url.toString() );
That's because I was having trouble to properly rediderct a page running
wicket on production mode. I spent days trying to find a solution. Finally,
I had to settle for the workaround but functional RedirectToUrlException.



Part 2, processing the IPN:

Once the payment has taken place, Paypal will send the IPN request to you.
If you haven't played with Paypal's IPN simulator, you can do so  here
  . Remember to provide
a valid url to IPN handler URL since IPN is a 3rd party trying to contact
your application. localhost will not do.

More on IPN

 
. Although, based on your post, you are already familiar with it.

As explained on this picture:
 

and on this
link:http://codeoftheday.blogspot.co.uk/2013/07/paypal-button-and-instant-payment_6.html,
Paypal sends an IPN message, which if the URL is valid, automatically sends
a http 200 response back. Then you need to send the exact IPN message back
to Paypal with the code "cmd=_notify-validate" (valid at time of writing).

When Paypal replies to you with a valid code, only then is advisable to do
your back end processing of the payments and everything else you need to do.

I've attached the code for PayPalIPNProcessingPortal class which is an empty
page and should be a bookmarkable page.

If you read through the code and try to understand it, it might be better
than me trying to explain step by step.

PayPalIPNProcessingPortal.java

  
PayPalIPNProcessingPortal.html

  
IPN_Parameter.java
  


Let me know if you have any questions. I am sorry if my code doesn't seem
clear enough. I work from home and although I try to make the code as
readable as possible for my future self, I don't have a team member to
code-review with.

All the best =0)
Lucas


--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Paypal-Integration-in-wicket-tp4670325p4670405.html
Sent from the Users forum mailing list archive at Nabble.com.

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