Infomessage ExternalLink in case of a missing URL

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Infomessage ExternalLink in case of a missing URL

hfriederichs
Hello to y'all,

I'm facing a nasty problem for a very simple requirement. In my application a user can enter an application code for working with that application (deployments and so on).
Now I want to add a button that opens a Wiki-documentation page for that application in a new browser tab. The URL for the wiki-page is stored in the same database table as is the application code. I implemented this at first with an ExternalLink, but I want to show an information message if the URL is not entered in the database.

I can't get that done with an ExternalLink, so I used a Link instead. Well, that gives the possibility to display info messages, but then I have to open the URL myself by something like:

public void onClick() {
    String docRef = getRefFromDb();
        if (docRef == null) {
                info("Please supply wiki-url first");
                return;
        }
        RedirectRequestHandler redirectRequestHandler = new RedirectRequestHandler(docRef);
        RequestCycle.get().scheduleRequestHandlerAfterCurrent(redirectRequestHandler);      
}

Obviously I leave my page when the link is clicked, so I added onBeforeRender() in which I add PopupSettings if the url is found, so at least I have a new window for the wiki-page (but I want a new tab). And if not, I have to nullify the PopupSettings...

This is very awkward.

Please, anyone, a simple solution?
Btw, I'm (still) using Wicket 1.5.4.

Regards, Hans
Reply | Threaded
Open this post in threaded view
|

Re: Infomessage ExternalLink in case of a missing URL

Martin Grigorov-4
Hi,

Here is one approach:
show ExternalLink if there is a url or a Label/empty
WebMarkupContainer+FeedbackMessage when there is no such url.
pseudo code:
if (docRef != null)
  add(new FragmentWithExternalLink("someId"))
else
  add(new FragmentWithMessage("someId"))


On Tue, Apr 16, 2013 at 1:58 PM, hfriederichs <[hidden email]> wrote:

> Hello to y'all,
>
> I'm facing a nasty problem for a very simple requirement. In my application
> a user can enter an application code for working with that application
> (deployments and so on).
> Now I want to add a button that opens a Wiki-documentation page for that
> application in a new browser tab. The URL for the wiki-page is stored in
> the
> same database table as is the application code. I implemented this at first
> with an ExternalLink, but I want to show an information message if the URL
> is not entered in the database.
>
> I can't get that done with an ExternalLink, so I used a Link instead. Well,
> that gives the possibility to display info messages, but then I have to
> open
> the URL myself by something like:
>
> public void onClick() {
>         String docRef = getRefFromDb();
>         if (docRef == null) {
>                 info("Please supply wiki-url first");
>                 return;
>         }
>         RedirectRequestHandler redirectRequestHandler = new
> RedirectRequestHandler(docRef);
>
>
> RequestCycle.get().scheduleRequestHandlerAfterCurrent(redirectRequestHandler);
> }
>
> Obviously I leave my page when the link is clicked, so I added
> onBeforeRender() in which I add PopupSettings if the url is found, so at
> least I have a new window for the wiki-page (but I want a new tab). And if
> not, I have to nullify the PopupSettings...
>
> This is very awkward.
>
> Please, anyone, a simple solution?
> Btw, I'm (still) using Wicket 1.5.4.
>
> Regards, Hans
>
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Infomessage-ExternalLink-in-case-of-a-missing-URL-tp4658015.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>
Reply | Threaded
Open this post in threaded view
|

Re: Infomessage ExternalLink in case of a missing URL

hfriederichs
Hi,

Thank you, but isn't that only possible during the first load of the page? When a user is finished with one application/wiki-url, he might enter a new code for another application, while he stays on the same page. At that point, I can't add or remove components anymore...?

Grts, Hans

Reply | Threaded
Open this post in threaded view
|

Re: Infomessage ExternalLink in case of a missing URL

Sven Meier
> while he stays on the same page. At that point, I can't add or remove components anymore...?

With Wicket you can replace components (almost) when ever you want. Just override #onConfigure() and use #addOrReplace().

Regards
Sven


On 04/16/2013 02:24 PM, hfriederichs wrote:

> Hi,
>
> Thank you, but isn't that only possible during the first load of the page?
> When a user is finished with one application/wiki-url, he might enter a new
> code for another application, while he stays on the same page. At that
> point, I can't add or remove components anymore...?
>
> Grts, Hans
>
>
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Infomessage-ExternalLink-in-case-of-a-missing-URL-tp4658015p4658021.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Infomessage ExternalLink in case of a missing URL

hfriederichs
But I want the button to be there allways, and to be clickable allways.
Just conditional behaviour on it's Click event

Can't this be done? It seems so simple?
Reply | Threaded
Open this post in threaded view
|

Re: Infomessage ExternalLink in case of a missing URL

Martin Grigorov-4
On Thu, Apr 18, 2013 at 12:37 PM, hfriederichs <[hidden email]>wrote:

> But I want the button to be there allways, and to be clickable allways.
> Just conditional behaviour on it's Click event
>
> Can't this be done? It seems so simple?
>

It is not complex.
Just provide a JavaScript array of urls and then iterate over them with
JavaScript...


>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Infomessage-ExternalLink-in-case-of-a-missing-URL-tp4658015p4658074.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>
Reply | Threaded
Open this post in threaded view
|

Re: Infomessage ExternalLink in case of a missing URL

hfriederichs
I'm sorry, but I don't understand you at all.

How is iteration over a javascript array of urls give me a button that opens a wikipage if a url can be found in a database, and how does that same iteration produce a feedback message if not?

I'm completely lost here.
Reply | Threaded
Open this post in threaded view
|

Re: Infomessage ExternalLink in case of a missing URL

Ernesto Reinaldo Barreiro-4
Make an AJAX link that goes back to the server, check if your URL if on DB.
If so redirect to the URL or produce a JavaScript that will do so at client
side. If not display a message that URL is not there (either by making a
component visible or executing a JavaScript that does that).


On Thu, Apr 18, 2013 at 3:20 PM, hfriederichs <[hidden email]> wrote:

> I'm sorry, but I don't understand you at all.
>
> How is iteration over a javascript array of urls give me a button that
> opens
> a wikipage if a url can be found in a database, and how does that same
> iteration produce a feedback message if not?
>
> I'm completely lost here.
>
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Infomessage-ExternalLink-in-case-of-a-missing-URL-tp4658015p4658085.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


--
Regards - Ernesto Reinaldo Barreiro
Reply | Threaded
Open this post in threaded view
|

Re: Infomessage ExternalLink in case of a missing URL

Martin Grigorov-4
In reply to this post by hfriederichs
On Thu, Apr 18, 2013 at 2:20 PM, hfriederichs <[hidden email]> wrote:

> I'm sorry, but I don't understand you at all.
>
> How is iteration over a javascript array of urls give me a button that
> opens
> a wikipage if a url can be found in a database, and how does that same
> iteration produce a feedback message if not?
>
> I'm completely lost here.
>

You said that you want the link/button to be always there and always
clickable.
So make your own Link/Button component that renders a JS array of urls (the
wiki pages urls). When clicked get the first element of the array (
http://www.w3schools.com/jsref/jsref_shift.asp) and show the wiki page,
when clicked again do the same with the new first element, etc. When the
array is empty show a label that there are no more wiki pages and disable
the link/button.

Wicket is server side web framework but this shouldn't stop you from
writing JavaScript when needed.


>
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Infomessage-ExternalLink-in-case-of-a-missing-URL-tp4658015p4658085.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


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