Re: wicket resources with nginx as frontend proxy

2014-05-20 Thread Martin Grigorov
Hi,


On Mon, May 19, 2014 at 11:03 PM, Marco Springer  wrote:

> Hi all,
>
> I'm trying to get something working that should be fairly easy, I think.
>
> I have Nginx sitting in-front of Jetty.
> An incoming URL could be: http://rage.glitchbox.nl/param1
> The proxy should proxy this to: http://localhost:8080/app/param1
> The webapplication is deployed as root application and is the only
> application
>

You say it is deployed as root app and below we see that WicketFilter
listens on /*.
So what is /app in this case ?!


> in that Jetty instance (or Tomcat if that would've been used)
> The wicket mount:
> mountPage("/app/${param}", AppPage.class); (the "param1" is a dynamic
> value)
>
> The actual generated HTML is fine.
> No images are loaded, no JS, nor any wicket resource.
> I've traced this back as to probably being a resource mapping or nginx
> config
> problem, but I'd love some confirmation on this.
> The generated HTML points to the resources as:
> "../../wicket/resource/etc"
> Due to the proxy setting, nginx sets this to:
> "/app/wicket/resource/etc..".
> Do I need to adjust the nginx configuration to filter on "/wicket/" and
> sent
> those requests through directly? Or do I need to do something about how
> wicket
> generates the paths for it's requests? No sure how to continue here.
>

Requests to /wicket/** should be no different to the other requests.
But if you want to change the values of these special segments then see
Application#newMapperContext. This won't help you much IMO.


>
> Also, some pages need authentication before they can be accessed, I'm using
> the wicket auth-roles package for this. But when that's being used,
> something
> weird is going on..
> If I request a page that needs authentication it does redirect me to the
> proper login page, that's fine (doesn't load the resources, images/css,
> though).
> Upon succesful login the browser is redirected to
> "localhost:8080/app/privilegedpage", instead of
> "http://rage.glitchbox.nl/privilegedpage";. Which I find very strange, is
> this
> also something in nginx that's wrong or wicket behavior?
>

it looks to me like not finished *reverse* proxy config.
Wicket generates only relative urls and will not generate
http://someHost/unless you explicitly ask for a full url.


> This login requirement is enforced through this code, which is in a
> AuthenticatedWebPage implementation:
> @Override
> protected void onConfigure() {
>   AuthenticatedWebApplication app = (AuthenticatedWebApplication)
> Application.get();
>
>   if(!AuthenticatedWebSession.get().isSignedIn()) {
> app.restartResponseAtSignInPage();
>   }
> }
>
> The SignInPage is the default SignInPage in the authroles package.
>
> I've googled around quite a bit for fellow nginx/wicket users. But to no
> real
> avail of a solution.
> Examples:
>
> http://www.mysticcoders.com/blog/how-to-setup-a-wicket-application-with-nginx-and-jetty/(where
>  I've taken my first attempt from and still seems to give the
> best result)
> I've also taken a look at:
>
> https://cwiki.apache.org/confluence/display/WICKET/Wicket+and+localized+URLs
> &
> http://blog.jteam.nl/2010/02/24/wicket-root-mounts/
> This for making "http://localhost:8080/app/param1"; into
> "http://localhost:8080/param1";, for the dynamic root mounts but seemed
> like a
> lot of hassle for something relatively easy, an http proxy in-front of
> jetty.
>
> If anyone can point me into the right direction, that would be great.
>
> The Nginx reverse proxy mapping:
> location / {
>   proxy_pass  http://localhost:8080/app/;
>   proxy_pass_header   Set-Cookie;
>   proxy_pass_header   X-Forwarded-For;
>   proxy_set_headerX-Real-IP $remote_addr;
>   proxy_pass_header   Host;
> }
>
> Wicket web.xml:
> (only thing noteworthy, as Im not sure this correct?)
> 
>   applicationname
>   /*
>

I think this should be /app/*


> 
>
> I'm using the WicketFilter, not the WicketServlet approach.
>
> If required, I'll whip up some quickstart tomorrow, not enough time for
> that
> now.
>

If you don't manage to setup it then please create a quickstart together
with nginx conf.


>
> Thanks in advance.
>
> Cheers,
> Marco Springer
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Re: Conditional input types

2014-05-20 Thread Simon B
Hi David, 

Your post reminded me of this quote from a (completely unrelated) post on
Stack Overflow: 

"Note that it is generally better to describe the goal, rather than the
strategy. 'Store changed file in Jar' is a strategy, whereas 'Save
preferences between runs' might be the goal"

http://stackoverflow.com/questions/5052311/how-can-an-app-use-files-inside-the-jar-for-read-and-write/5052359#5052359

You seem to have your mind set on the strategy which doesn't really sit well
with Wicket.  I can understand your frustration as if you had direct access
to the html as you might with a jsp then you could you achieve your goal
very quickly.

As I understand your post, Wicket doesn't work in the way that would allow
you to achieve your goal with the strategy that you've chosen.



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Conditional-input-types-tp4665924p4665955.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: Conditional input types

2014-05-20 Thread Ernesto Reinaldo Barreiro
Hi,


On Tue, May 20, 2014 at 9:55 AM, Simon B  wrote:

> Hi David,
>
> Your post reminded me of this quote from a (completely unrelated) post on
> Stack Overflow:
>
> "Note that it is generally better to describe the goal, rather than the
> strategy. 'Store changed file in Jar' is a strategy, whereas 'Save
> preferences between runs' might be the goal"
>
>
> http://stackoverflow.com/questions/5052311/how-can-an-app-use-files-inside-the-jar-for-read-and-write/5052359#5052359
>
> You seem to have your mind set on the strategy which doesn't really sit
> well
> with Wicket.  I can understand your frustration as if you had direct access
> to the html as you might with a jsp then you could you achieve your goal
> very quickly.
>

Why? What he want can be easily achieved with panels and the factory
pattern I mentioned on a previous e-mail. IMHO the problem just arises
because he's trying to use wicket in a way it is not intended to be used.


> As I understand your post, Wicket doesn't work in the way that would allow
> you to achieve your goal with the strategy that you've chosen.
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Conditional-input-types-tp4665924p4665955.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
>
>


-- 
Regards - Ernesto Reinaldo Barreiro


Re: Conditional input types

2014-05-20 Thread Martin Grigorov
On Tue, May 20, 2014 at 11:08 AM, Ernesto Reinaldo Barreiro <
reier...@gmail.com> wrote:

> Hi,
>
>
> On Tue, May 20, 2014 at 9:55 AM, Simon B  wrote:
>
> > Hi David,
> >
> > Your post reminded me of this quote from a (completely unrelated) post on
> > Stack Overflow:
> >
> > "Note that it is generally better to describe the goal, rather than the
> > strategy. 'Store changed file in Jar' is a strategy, whereas 'Save
> > preferences between runs' might be the goal"
> >
> >
> >
> http://stackoverflow.com/questions/5052311/how-can-an-app-use-files-inside-the-jar-for-read-and-write/5052359#5052359
> >
> > You seem to have your mind set on the strategy which doesn't really sit
> > well
> > with Wicket.  I can understand your frustration as if you had direct
> access
> > to the html as you might with a jsp then you could you achieve your goal
> > very quickly.
> >
>
> Why? What he want can be easily achieved with panels and the factory
> pattern I mentioned on a previous e-mail. IMHO the problem just arises
> because he's trying to use wicket in a way it is not intended to be used.
>

I am not sure why you say that Wicket is not prepared for such use case.
As I said Fragment component is designed exactly for this use case.
See http://wicket.apache.org/guide/guide/keepControl.html#keepControl_5 and
http://www.wicket-library.com/wicket-examples-6.0.x/compref/wicket/bookmarkable/org.apache.wicket.examples.compref.FragmentPage

For this use case the code is:




   



   




And the java code:
String type = isText ? "text" : "check";

add(new Fragment("formElement", type, this));


For this simple use case a Fragment is enough. If there are many different
options (let's say more than 5) then the approach with the factory and the
Panels would be better.


>
> > As I understand your post, Wicket doesn't work in the way that would
> allow
> > you to achieve your goal with the strategy that you've chosen.
> >
> >
> >
> > --
> > View this message in context:
> >
> http://apache-wicket.1842946.n4.nabble.com/Conditional-input-types-tp4665924p4665955.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
> >
> >
>
>
> --
> Regards - Ernesto Reinaldo Barreiro
>


Re: Conditional input types

2014-05-20 Thread Simon B
Ernesto, Martin, 

Just to clarify a bit. 

I didn't say that you couldn't do it with wicket.  

Simply that david.latan's strategy - 

> I couldn't manage to use AttributeModifier in order to assign a CheckBox
> to the input.
http://apache-wicket.1842946.n4.nabble.com/Conditional-input-types-tp4665924p4665938.html
: 

Wouldn't work with Wicket as it treats TextFields and CheckBoxes as
different FormComponents,  not as an html element with can change its
behaviour completely by modifying one attribute.

That's what I meant when I said: 

"As I understand your post, Wicket doesn't work in the way that would allow
you to achieve your goal with the strategy that you've chosen."

As far as using fragments of factories within wicket I'm sure both work and
have their merits in different contexts.

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Conditional-input-types-tp4665924p4665958.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: Conditional input types

2014-05-20 Thread david.latan
Yeah you're right, i implemented this solution and it works. For what i
undertstood fragments where meant to be use for having a div content
depending on the call of the page (div login or div account info for
exemple). but yeah they work great for this problem too, has i have less
than 5 differents fragments.

So thank you, this thread is pretty mush closed, others solutions should be
usable too, but fragments seems the way to go.

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Conditional-input-types-tp4665924p4665961.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: Page rendering from quartz job

2014-05-20 Thread Sandor Feher
Huh guys, I just see the my topic became hot :).
So far so good. Now I get wicket application instance but RequestCycle is
null of course.
How can I get over that ?
Thnx!





--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Page-rendering-from-quartz-job-tp4665860p4665962.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: Page rendering from quartz job

2014-05-20 Thread Martin Grigorov
read my earlier answer with ComponentRenderer.java

Martin Grigorov
Wicket Training and Consulting


On Tue, May 20, 2014 at 4:14 PM, Sandor Feher  wrote:

> Huh guys, I just see the my topic became hot :).
> So far so good. Now I get wicket application instance but RequestCycle is
> null of course.
> How can I get over that ?
> Thnx!
>
>
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Page-rendering-from-quartz-job-tp4665860p4665962.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: Page rendering from quartz job

2014-05-20 Thread Sandor Feher
Sorry Martin!
My code mentioned based on your comment:

https://github.com/apache/wicket/blob/master/wicket-core/src/main/java/org/apache/wicket/core/util/string/ComponentRenderer.java#L46for

 pageHtml = ComponentRenderer.renderPage(pageProvider); 
throws 
org.apache.wicket.WicketRuntimeException: There is no application attached
to current thread
because  Application application = Application.get(); returns null

If I use Application application = Application.get("wicket");
then I get application instance but RequestCycle.get() also returns null.

Did I miss something or I go on completely wrong way ?

Thnx, Sandor






--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Page-rendering-from-quartz-job-tp4665860p4665964.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: Page rendering from quartz job

2014-05-20 Thread Martin Grigorov
https://github.com/apache/wicket/blob/master/wicket-core/src/main/java/org/apache/wicket/core/util/string/ComponentRenderer.java#L54shows
how to create a RequestCycle
and
https://github.com/apache/wicket/blob/master/wicket-core/src/main/java/org/apache/wicket/core/util/string/ComponentRenderer.java#L58how
to set it as ThreadLocal

Martin Grigorov
Wicket Training and Consulting


On Tue, May 20, 2014 at 4:40 PM, Sandor Feher  wrote:

> Sorry Martin!
> My code mentioned based on your comment:
>
>
> https://github.com/apache/wicket/blob/master/wicket-core/src/main/java/org/apache/wicket/core/util/string/ComponentRenderer.java#L46for
>
>  pageHtml = ComponentRenderer.renderPage(pageProvider);
> throws
> org.apache.wicket.WicketRuntimeException: There is no application attached
> to current thread
> because  Application application = Application.get(); returns null
>
> If I use Application application = Application.get("wicket");
> then I get application instance but RequestCycle.get() also returns null.
>
> Did I miss something or I go on completely wrong way ?
>
> Thnx, Sandor
>
>
>
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Page-rendering-from-quartz-job-tp4665860p4665964.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
>
>


wicket textinput field

2014-05-20 Thread Damilare Olowoniyi
HI,

I'm currently using wicket as my part MVC in my controller and at the
moment i have an Array of strings within a parameter named "operations"
 for example whats inside the parameter:

   - boo
   - far
   - bar
   - mon

assuming the array are random each time, as in its not just the same
strings from above

So now i want to output those strings within the parameter "operations"
into individual Input fields.

for instance:

 boo ==> a input box
far ==> a input box
bar ==>a  input box

and so on...

how would i go about doing this with wicket?

Thanks