You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by hfriederichs <h....@ohra.nl> on 2012/06/01 15:24:13 UTC

Conditional Popup

Hello,

I have a wicket PopupPage that answers a wicket link, but I don't want it to
popup when certain conditions are not met. In that case I want an
info-message.

So I tried something like:
final Link<String> theLink = new Link<String>(...) {
				
public void onClick() {
if (condition) {
   info("Do this first");
} else {
  setPopupSettings(thePopupSettings);	
  setResponsePage(thePopupPage);
}
};

But no matter what I try, the popuppage always comes.


						

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

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


Re: Conditional Popup

Posted by Thomas Götz <to...@decoded.de>.
What about the AjaxLink alternative I already suggested?

   -Tom


On 04.06.2012 at 09:35 hfriederichs wrote:

> No suggestions? Anyone?


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


Re: Conditional Popup

Posted by hfriederichs <h....@ohra.nl>.
No suggestions? Anyone?

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

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


Re: Conditional Popup

Posted by Thomas Götz <to...@decoded.de>.
On 04.06.2012 at 13:21 hfriederichs wrote:

> 
> Thomas Götz-2 wrote
>> 
>> As an alternative, you could use an AjaxLink and push the popup-opener JS
>> to teh frontend, then you could have your decision logic (wether to open
>> it or not) in the backend (Wicket layer).
>> 
>> 
> 
> But, how would you do that?
> 
> if  (condition) {
>   info("Do this first");
> } else {
>   activate JS-popup-opener ????
> }

Yes, this would be a possible solution, maybe something like that:

AjaxLink link = new AjaxLink("link") {
    @Override
    public void onClick(AjaxRequestTarget target) {
        if (condition) {
            info("...");
            // target.add(feedbackPanel);
        } else {
            target.appendJavaScript("Wicket.$('" + myPopup.getMarkupId() + "').open();");
        }
    }
};
add(link);


> And furthermore, I need to pass data to the popup-page, so I would have to
> stick that in the Session?

You could also pass a model to the Page's constructor e.g.

Cheers,
   -Tom


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


Re: Conditional Popup

Posted by hfriederichs <h....@ohra.nl>.
Thomas Götz-2 wrote
> 
> As an alternative, you could use an AjaxLink and push the popup-opener JS
> to teh frontend, then you could have your decision logic (wether to open
> it or not) in the backend (Wicket layer).
>    
> 

But, how would you do that?

if  (condition) {
   info("Do this first");
} else {
   activate JS-popup-opener ????
}

And furthermore, I need to pass data to the popup-page, so I would have to
stick that in the Session?

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

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


Re: Conditional Popup

Posted by Thomas Götz <to...@decoded.de>.
As an alternative, you could use an AjaxLink and push the popup-opener JS to teh frontend, then you could have your decision logic (wether to open it or not) in the backend (Wicket layer).

   -Tom




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


Re: Conditional Popup

Posted by Thomas Götz <to...@decoded.de>.
I thought you might have some condition that you could evaluate in JS. This is the reason I asked for a short quickstart, it simply eases discussion.

   -Tom


On 01.06.2012 at 19:19 hfriederichs wrote:

> I'm sorry, but I don't understand your code. My condition is in the
> Java/Wicket-layer, how can you put that between double quotes?


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


Re: Conditional Popup

Posted by hfriederichs <h....@ohra.nl>.
Thomas Götz-2 wrote
> 
> 
> PopupSettings popupSettings = new PopupSettings() {
>     @Override
>     public String getPopupJavaScript() {
>         return "if(!condition) return false; " +
> super.getPopupJavaScript();
>     }
> };
> 
> 

I'm sorry, but I don't understand your code. My condition is in the
Java/Wicket-layer, how can you put that between double quotes?


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

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


Re: Conditional Popup

Posted by Thomas Götz <to...@decoded.de>.
As I suppose that you want to create a Javascript popup (i.e. a Wicket Link with PopupSettings), you need to decide wether to open the popup or not in the frontend (Javascript layer), not in the onClick() of the Link. So you could try something like this:

PopupSettings popupSettings = new PopupSettings() {
    @Override
    public String getPopupJavaScript() {
        return "if(!condition) return false; " + super.getPopupJavaScript();
    }
};

Link link = new Link("link") {
    @Override
    public void onClick() {
        // ...
    }

};
link.setPopupSettings(popupSettings);
add(link);

   -Tom



On 01.06.2012 at 16:40 hfriederichs wrote:

> For other questions I had earlier on, I created quickstarts, but, since I'm
> working on a very complex application, I couldn't reproduce the problem in a
> quickstart. I spent hours and hours copying more and more of my application
> into the quickstart, but to no avail.
> 
> So again, it's a simple question: how to make a conditional popup.


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


Re: Conditional Popup

Posted by hfriederichs <h....@ohra.nl>.
Martin Grigorov-4 wrote
> 
> try with:
> 
> if (condition) { setPopupSettings(nonNull) } else { setPopupSettings(null)
> }
> 
> 

This doesn't work. The condition has to be checked every time the link is
clicked, so within the onCLick().
setPopupSettings(null) gives the current page as popup.

Maybe this information is relevant: The link is part of a row in a repeater
(within the populateItem of a ListView).



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

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


Re: Conditional Popup

Posted by Martin Grigorov <mg...@apache.org>.
try with:

if (condition) { setPopupSettings(nonNull) } else { setPopupSettings(null) }

On Fri, Jun 1, 2012 at 5:40 PM, hfriederichs <h....@ohra.nl> wrote:
> For other questions I had earlier on, I created quickstarts, but, since I'm
> working on a very complex application, I couldn't reproduce the problem in a
> quickstart. I spent hours and hours copying more and more of my application
> into the quickstart, but to no avail.
>
> So again, it's a simple question: how to make a conditional popup.
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Conditional-Popup-tp4649649p4649654.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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


Re: Conditional Popup

Posted by hfriederichs <h....@ohra.nl>.
For other questions I had earlier on, I created quickstarts, but, since I'm
working on a very complex application, I couldn't reproduce the problem in a
quickstart. I spent hours and hours copying more and more of my application
into the quickstart, but to no avail.

So again, it's a simple question: how to make a conditional popup.

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

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


Re: Conditional Popup

Posted by Thomas Götz <to...@decoded.de>.
To create a quickstart normally costs me around 5-7 seconds (copy/paste is my friend) ;-)
Isolating the problem is another question, right. But in your case this sound rather trivial. In my experience a lot of problems are solved easyly by creating a quickstart, in most cases because then I realize that I did something wrong ;-)

   -Tom


On 01.06.2012 at 16:06 hfriederichs wrote:

> A quick-start costs me one or two hours; in the end, maybe I will. But I
> think this is a reasonably simple question, so I'll await some
> straightforward suggestions first.


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


Re: Conditional Popup

Posted by hfriederichs <h....@ohra.nl>.
A quick-start costs me one or two hours; in the end, maybe I will. But I
think this is a reasonably simple question, so I'll await some
straightforward suggestions first.

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

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


Re: Conditional Popup

Posted by Thomas Götz <to...@decoded.de>.
Could you please provide a quickstart or post the interesting HTML and Java snippets?

   -Tom


On 01.06.2012 at 15:24 hfriederichs wrote:

> Hello,
> 
> I have a wicket PopupPage that answers a wicket link, but I don't want it to
> popup when certain conditions are not met. In that case I want an
> info-message.
> 
> So I tried something like:
> final Link<String> theLink = new Link<String>(...) {
> 				
> public void onClick() {
> if (condition) {
>   info("Do this first");
> } else {
>  setPopupSettings(thePopupSettings);	
>  setResponsePage(thePopupPage);
> }
> };
> 
> But no matter what I try, the popuppage always comes.
> 
> 
> 						
> 
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Conditional-Popup-tp4649649.html
> Sent from the Users forum mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 


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