Re: [wiQuery] Creating a script without a component

2010-10-18 Thread Peter Munro
@Jeremy: oops! Sorry, hadn't realised it had its own list. Next time... :-)

@Julien: Aha. I understand. Many thanks, I will try it now.

Peter

On Mon, Oct 18, 2010 at 4:54 PM, julien roche AKA indiana_jules <
roche@gmail.com> wrote:

> Or
>
> return new JsQuery().$(".check-login").chain("attr", "'href'", "'#'");
>
> Julien Roche
>
>
> On Mon, Oct 18, 2010 at 5:53 PM, julien roche AKA indiana_jules <
> roche@gmail.com> wrote:
>
> > Hi Peter,
> >
> > The "right" way for your case will be:
> >
> > add(new WiqueryAbstractBehavior() {
> >public JsStatement statement() {
> >   return new JsStatement ().$(null, ".check-login").chain("attr",
> > "'href'", "'#'");
> >}
> > });
> >
> > In the standard process, we will never have an empty component when the
> > renderHead method is called. Maybe we will renforce the code to enable
> your
> > approach.
> >
> > Regards
> >
> > Julien Roche
> >
> >
> >
> > On Mon, Oct 18, 2010 at 5:39 PM, Jeremy Thomerson <
> > jer...@wickettraining.com> wrote:
> >
> >> On Mon, Oct 18, 2010 at 10:02 AM, Peter Munro 
> >> wrote:
> >>
> >> > Hi,
> >> >
> >> > I'd like to set up a JQuery script in my page header to change the
> >> > attributes of all links with a specified class, so in my Java code I
> >> tried
> >> > this:
> >> >
> >> >JsQuery linkQuery = new JsQuery();
> >> >linkQuery.$(".check-login").chain("attr", "'href'", "'#'");
> >> >add(new HeaderContributor(linkQuery));
> >> >
> >> > I'm not sure if this code should do what I want yet, but in any case I
> >> get
> >> > a
> >> > NullPointerException (I'm using wiQuery 1.0.2):
> >> >
> >> > java.lang.NullPointerException
> >> > at
> >> >
> org.odlabs.wiquery.core.javascript.JsQuery.renderHead(JsQuery.java:133)
> >> >
> >> >
> >> > I looked at the JsQuery.java and it looks like renderHead() assumes
> >> > 'component' is initialised, but I'm using the no-arg constructor.
> >> >
> >> > Am I going about this the wrong way (and if so, what's the right
> way?!)
> >> or
> >> > is this a bug?
> >> >
> >> > Many thanks,
> >> > Peter
> >> >
> >>
> >>
> >> Have you tried emailing the wiquery users' list?  I believe it's
> >> wiqu...@googlegroups.com
> >> --
> >> Jeremy Thomerson
> >> http://www.wickettraining.com
> >>
> >
> >
>


[wiQuery] Creating a script without a component

2010-10-18 Thread Peter Munro
Hi,

I'd like to set up a JQuery script in my page header to change the
attributes of all links with a specified class, so in my Java code I tried
this:

JsQuery linkQuery = new JsQuery();
linkQuery.$(".check-login").chain("attr", "'href'", "'#'");
add(new HeaderContributor(linkQuery));

I'm not sure if this code should do what I want yet, but in any case I get a
NullPointerException (I'm using wiQuery 1.0.2):

java.lang.NullPointerException
 at org.odlabs.wiquery.core.javascript.JsQuery.renderHead(JsQuery.java:133)


I looked at the JsQuery.java and it looks like renderHead() assumes
'component' is initialised, but I'm using the no-arg constructor.

Am I going about this the wrong way (and if so, what's the right way?!) or
is this a bug?

Many thanks,
Peter


Re: [wiquery] How to open a modal dialog from a Link?

2010-10-14 Thread Peter Munro
That works beautifully. Thanks Ernesto.

I also made a small mod to remove the 'href' on the client side so that it
just opens the dialog and doesn't follow the link:

JsQuery linkQuery = new JsQuery(link);
linkQuery.$().chain("attr", "'href'", "'#'");
link.add(new HeaderContributor(linkQuery));

Thanks again,
Peter

On Tue, Oct 12, 2010 at 8:27 PM, Ernesto Reinaldo Barreiro <
reier...@gmail.com> wrote:

> Use JavaScript to do that on the client side? See method
>
> /**Method to open the dialog
> * @return the associated JsStatement
> */
>public JsStatement open() {
>return new JsQuery(this).$().chain("dialog", "'open'");
>}
>
> on Dialog class which generates the needed JavaScript. I haven't tried this
> but
>
> Open Dialog
>
> ---
>
> WebMarkupContainer link =  new WebMarkupContainer("link");
>link.add(new AttributeModifier("onclick", new
> AbstractReadOnlyModel() {
>
>@Override
>public String getObject() {
>return new
> JsQuery(dialog).$().chain("dialog",
> "'open'").render().toString();
>}
>}));
>
> might work.
>
> Ernesto
>
>
>
> On Tue, Oct 12, 2010 at 8:25 PM, Peter Munro  wrote:
> > Hi,
> >
> > I'm using wiQuery and have a demo application with a Button that opens a
> > modal dialog successfully, but I'd like to use Links instead of Buttons,
> so
> > I'm replacing this:
> > Open dialog
> > with an anchor/Link:
> > Open dialog
> >
> > and in my Java code, replacing this:
> > Button button = new Button("open-dialog");
> > with this:
> > Link link = new Link("open-dialog") {
> >public void onClick() {
> >System.out.println("clicked");
> >}
> > };
> >
> > When I run it and click the link, the Dialog appears for half a second or
> > so, then the page refreshes itself as a result of the  tag's HTTP
> > request/response.
> >
> > I'd like for the dialog to appear locally WITHOUT any HTTP
> request/response.
> > And further (ideally), if Javascript is disabled, then have the onClick()
> > method invoked as normal.
> >
> > Any ideas how I can do this?
> >
> > Many thanks,
> > Peter
> >
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


[wiquery] How to open a modal dialog from a Link?

2010-10-12 Thread Peter Munro
Hi,

I'm using wiQuery and have a demo application with a Button that opens a
modal dialog successfully, but I'd like to use Links instead of Buttons, so
I'm replacing this:
Open dialog
with an anchor/Link:
Open dialog

and in my Java code, replacing this:
Button button = new Button("open-dialog");
with this:
Link link = new Link("open-dialog") {
public void onClick() {
System.out.println("clicked");
}
};

When I run it and click the link, the Dialog appears for half a second or
so, then the page refreshes itself as a result of the  tag's HTTP
request/response.

I'd like for the dialog to appear locally WITHOUT any HTTP request/response.
And further (ideally), if Javascript is disabled, then have the onClick()
method invoked as normal.

Any ideas how I can do this?

Many thanks,
Peter


Re: Authorization using PageParameters

2010-10-06 Thread Peter Munro
Huge thanks to both Eike and Martin.

They both work, so I'm figuring out the best approach. I'll probably go with
Martin's.
BTW, for anyone googling the archive, either:

   - WebRequestCycle.get().getPageParameters(), or
   - WebRequestCycle.get().getRequest().getParameter("myparam")

will do the trick.

Thanks again,
Peter


On Wed, Oct 6, 2010 at 2:32 PM, Martin Grigorov wrote:

> Try with WebRequestCycle.get().getWebRequest().getParameters() or something
> like that.
>
> On Wed, Oct 6, 2010 at 2:53 PM, Peter Munro  wrote:
>
> > Hi all,
> >
> > I'm confused... I'd like to setup authorization for a page, where the
> > authorization decision is based on the parameters passed to the page. For
> > example, http://blahblah/MyPage/?date=2010-10-06 would authorize
> correctly
> > (show the page), but previous dates would not.
> >
> > Subclassing MyAuthorisationStrategy and overriding isPageAuthorized(final
> > Class pageClass) doesn't work, since I don't get passed the page
> > parameters.
> >
> > What's the best way?
> >
> > Many thanks,
> > Peter
> >
>


Authorization using PageParameters

2010-10-06 Thread Peter Munro
Hi all,

I'm confused... I'd like to setup authorization for a page, where the
authorization decision is based on the parameters passed to the page. For
example, http://blahblah/MyPage/?date=2010-10-06 would authorize correctly
(show the page), but previous dates would not.

Subclassing MyAuthorisationStrategy and overriding isPageAuthorized(final
Class pageClass) doesn't work, since I don't get passed the page
parameters.

What's the best way?

Many thanks,
Peter