You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Simon Kitching <si...@rhe.co.nz> on 2007/03/29 08:00:15 UTC

jscookmenu and links (not actions)

Hi,

I'd like to have a jscookmenu entry that loads a url into a popup window 
rather than perform a submit.

The file MyFacesHack.js appears to be making an effort to allow this in 
function cmItemMouseUp:

if (link != null)
{
     if (link.match(/^\w*:A\]\w*:\/\//) != null ) {
         // Link is a URL
         link = link.replace(/^\w*:A\]/, "");  // Remove JSF ID
         window.open (link, target);
     } else if (link.match(/^\w*:A\]\w*:/) != null ) {
         // Link is a script method
         ....
     } else {
         // Link is a JSF action
         ....


However I can't figure out what I need to put in my JSP file (ie the 
t:navigationMenuItem tags) to get that "Link is a URL" block to trigger.

Can anyone enlighten me?

BTW, I'm using tomahawk 1.1.3 + JSP.

Thanks,

Simon

Re: jscookmenu and links (not actions)

Posted by Mike Kienenberger <mk...@gmail.com>.
On 3/29/07, Simon Kitching <si...@rhe.co.nz> wrote:

> Mike wrote:
>  >     (/^\w*:A\]\w*:\/\//) != null ) {
>  >
>  >     start-of-string any-number-of-alphanumerics colon A ]
>  >     any-number-of-alphanumerics colon W
>
> Almost; format matched is:
>    menu-id :A] protocol://url
> where ":A]" is a literal used as a separator between the two bits.

Ok.  I see.
It's double-escaped-slash, not W :-)  Looks the same in my web browser :-)

Re: jscookmenu and links (not actions)

Posted by Simon Kitching <si...@rhe.co.nz>.
Thanks to both of you for your help.

I've got things working now, and have updated the wiki docs:
   http://wiki.apache.org/myfaces/Dynamic_Menus_with_JSCookMenu

As noted there, encoding a url into the action field does work - but 
only when the url is absolute.

So instead I used
   action="javascript:showFoo();"
and the showFoo method then gets the url to open from a hidden field in 
the page so I can calculate it dynamically. Note that I explicitly 
wanted to open the url in a new window (otherwise I would just be using 
the action form).

Mike wrote:
 >     (/^\w*:A\]\w*:\/\//) != null ) {
 >
 >     start-of-string any-number-of-alphanumerics colon A ]
 >     any-number-of-alphanumerics colon W

Almost; format matched is:
   menu-id :A] protocol://url
where ":A]" is a literal used as a separator between the two bits.

Thanks again,

Simon

Sorin Silaghi wrote:
> from what I've seen if you put any EL in the action field it will try to 
> use the outcome with jsf's navigation system... so I don't think any JS 
> would work like that.. and there is not much you can do about it because 
> you would have to specify if what you are returning from the backing 
> bean is to be interpreted for navigation rules or just as a plain URL...
> 
> On 3/29/07, *Mike Kienenberger* <mkienenb@gmail.com 
> <ma...@gmail.com>> wrote:
> 
>     Does the attribute take a value binding?  Maybe a temporary workaround
>     would be to return javascript that navigates to a url.
> 
>     The pattern to match looks like it might be
> 
>     (/^\w*:A\]\w*:\/\//) != null ) {
> 
>     start-of-string any-number-of-alphanumerics colon A ]
>     any-number-of-alphanumerics colon W
> 
>     blahblahblah:A]blahblahblah:W
> 
>     Weird.   Maybe I'm missreading it.
> 
>     On 3/29/07, Sorin Silaghi < sorin7486@gmail.com
>     <ma...@gmail.com>> wrote:
>      > if you just want a static URL it's easy ... you can put it in the
>     action
>      > field. You can even put JS in there so that you get the pop-up
>     you want. The
>      > problem appears if you want it to be dynamic. For example if you
>     want to
>      > generate the URL in the backing bean you have to find another
>     way. I'm
>      > trying to do the same thing but don't have a solution yet. I need
>     the link
>      > to be outside my web app but untill now I've only been able to
>     redirect
>      > inside the JSF app
>      >
>      >
>      > On 3/29/07, Simon Kitching <simon.kitching@rhe.co.nz
>     <ma...@rhe.co.nz>> wrote:
>      > > Hi,
>      > >
>      > > I'd like to have a jscookmenu entry that loads a url into a
>     popup window
>      > > rather than perform a submit.
>      > >
>      > > The file MyFacesHack.js appears to be making an effort to allow
>     this in
>      > > function cmItemMouseUp:
>      > >
>      > > if (link != null)
>      > > {
>      > >      if (link.match(/^\w*:A\]\w*:\/\//) != null ) {
>      > >          // Link is a URL
>      > >          link = link.replace(/^\w*:A\]/, "");  // Remove JSF ID
>      > >           window.open (link, target);
>      > >      } else if (link.match(/^\w*:A\]\w*:/) != null ) {
>      > >          // Link is a script method
>      > >          ....
>      > >      } else {
>      > >          // Link is a JSF action
>      > >          ....
>      > >
>      > >
>      > > However I can't figure out what I need to put in my JSP file
>     (ie the
>      > > t:navigationMenuItem tags) to get that "Link is a URL" block to
>     trigger.
>      > >
>      > > Can anyone enlighten me?
>      > >
>      > > BTW, I'm using tomahawk 1.1.3 + JSP.
>      > >
>      > > Thanks,
>      > >
>      > > Simon
>      > >
>      >
>      >
> 
> 


Re: jscookmenu and links (not actions)

Posted by Sorin Silaghi <so...@gmail.com>.
from what I've seen if you put any EL in the action field it will try to use
the outcome with jsf's navigation system... so I don't think any JS would
work like that.. and there is not much you can do about it because you would
have to specify if what you are returning from the backing bean is to be
interpreted for navigation rules or just as a plain URL...

On 3/29/07, Mike Kienenberger <mk...@gmail.com> wrote:
>
> Does the attribute take a value binding?  Maybe a temporary workaround
> would be to return javascript that navigates to a url.
>
> The pattern to match looks like it might be
>
> (/^\w*:A\]\w*:\/\//) != null ) {
>
> start-of-string any-number-of-alphanumerics colon A ]
> any-number-of-alphanumerics colon W
>
> blahblahblah:A]blahblahblah:W
>
> Weird.   Maybe I'm missreading it.
>
> On 3/29/07, Sorin Silaghi <so...@gmail.com> wrote:
> > if you just want a static URL it's easy ... you can put it in the action
> > field. You can even put JS in there so that you get the pop-up you want.
> The
> > problem appears if you want it to be dynamic. For example if you want to
> > generate the URL in the backing bean you have to find another way. I'm
> > trying to do the same thing but don't have a solution yet. I need the
> link
> > to be outside my web app but untill now I've only been able to redirect
> > inside the JSF app
> >
> >
> > On 3/29/07, Simon Kitching <si...@rhe.co.nz> wrote:
> > > Hi,
> > >
> > > I'd like to have a jscookmenu entry that loads a url into a popup
> window
> > > rather than perform a submit.
> > >
> > > The file MyFacesHack.js appears to be making an effort to allow this
> in
> > > function cmItemMouseUp:
> > >
> > > if (link != null)
> > > {
> > >      if (link.match(/^\w*:A\]\w*:\/\//) != null ) {
> > >          // Link is a URL
> > >          link = link.replace(/^\w*:A\]/, "");  // Remove JSF ID
> > >          window.open (link, target);
> > >      } else if (link.match(/^\w*:A\]\w*:/) != null ) {
> > >          // Link is a script method
> > >          ....
> > >      } else {
> > >          // Link is a JSF action
> > >          ....
> > >
> > >
> > > However I can't figure out what I need to put in my JSP file (ie the
> > > t:navigationMenuItem tags) to get that "Link is a URL" block to
> trigger.
> > >
> > > Can anyone enlighten me?
> > >
> > > BTW, I'm using tomahawk 1.1.3 + JSP.
> > >
> > > Thanks,
> > >
> > > Simon
> > >
> >
> >
>

Re: jscookmenu and links (not actions)

Posted by Mike Kienenberger <mk...@gmail.com>.
Does the attribute take a value binding?  Maybe a temporary workaround
would be to return javascript that navigates to a url.

The pattern to match looks like it might be

(/^\w*:A\]\w*:\/\//) != null ) {

start-of-string any-number-of-alphanumerics colon A ]
any-number-of-alphanumerics colon W

blahblahblah:A]blahblahblah:W

Weird.   Maybe I'm missreading it.

On 3/29/07, Sorin Silaghi <so...@gmail.com> wrote:
> if you just want a static URL it's easy ... you can put it in the action
> field. You can even put JS in there so that you get the pop-up you want. The
> problem appears if you want it to be dynamic. For example if you want to
> generate the URL in the backing bean you have to find another way. I'm
> trying to do the same thing but don't have a solution yet. I need the link
> to be outside my web app but untill now I've only been able to redirect
> inside the JSF app
>
>
> On 3/29/07, Simon Kitching <si...@rhe.co.nz> wrote:
> > Hi,
> >
> > I'd like to have a jscookmenu entry that loads a url into a popup window
> > rather than perform a submit.
> >
> > The file MyFacesHack.js appears to be making an effort to allow this in
> > function cmItemMouseUp:
> >
> > if (link != null)
> > {
> >      if (link.match(/^\w*:A\]\w*:\/\//) != null ) {
> >          // Link is a URL
> >          link = link.replace(/^\w*:A\]/, "");  // Remove JSF ID
> >          window.open (link, target);
> >      } else if (link.match(/^\w*:A\]\w*:/) != null ) {
> >          // Link is a script method
> >          ....
> >      } else {
> >          // Link is a JSF action
> >          ....
> >
> >
> > However I can't figure out what I need to put in my JSP file (ie the
> > t:navigationMenuItem tags) to get that "Link is a URL" block to trigger.
> >
> > Can anyone enlighten me?
> >
> > BTW, I'm using tomahawk 1.1.3 + JSP.
> >
> > Thanks,
> >
> > Simon
> >
>
>

Re: jscookmenu and links (not actions)

Posted by Sorin Silaghi <so...@gmail.com>.
if you just want a static URL it's easy ... you can put it in the action
field. You can even put JS in there so that you get the pop-up you want. The
problem appears if you want it to be dynamic. For example if you want to
generate the URL in the backing bean you have to find another way. I'm
trying to do the same thing but don't have a solution yet. I need the link
to be outside my web app but untill now I've only been able to redirect
inside the JSF app

On 3/29/07, Simon Kitching <si...@rhe.co.nz> wrote:
>
> Hi,
>
> I'd like to have a jscookmenu entry that loads a url into a popup window
> rather than perform a submit.
>
> The file MyFacesHack.js appears to be making an effort to allow this in
> function cmItemMouseUp:
>
> if (link != null)
> {
>      if (link.match(/^\w*:A\]\w*:\/\//) != null ) {
>          // Link is a URL
>          link = link.replace(/^\w*:A\]/, "");  // Remove JSF ID
>          window.open (link, target);
>      } else if (link.match(/^\w*:A\]\w*:/) != null ) {
>          // Link is a script method
>          ....
>      } else {
>          // Link is a JSF action
>          ....
>
>
> However I can't figure out what I need to put in my JSP file (ie the
> t:navigationMenuItem tags) to get that "Link is a URL" block to trigger.
>
> Can anyone enlighten me?
>
> BTW, I'm using tomahawk 1.1.3 + JSP.
>
> Thanks,
>
> Simon
>