Portlet 1.0 on Wicket 1.4?

2009-03-03 Thread German Morales
Hi all,

I've been reading in different threads that Wicket 1.4 already supports
Portlet 2.0 API.
We are already trying it with different success, in different portals.

We have an application being developed in Wicket 1.3.5 (last stable release
so far), and we planned to switch to 1.4.
But customers have yet not migrated to portals with Portlet 2.0 support, and
perhaps they won't in some (long) time.
That means that perhaps we get stuck in wicket 1.3.x, or we have to maintain
2 versions (since wicket 1.4 is not compatible with 1.3).

So i was thinking... what are the chances of getting Portlet-1.0-only
support in Wicket 1.4?
Could the portlet support in wicket 1.4 be separated somehow, so we can plug
Portlet 1.0 for some customers, Portlet 2.0 for others?

Thanks in advance,

German


Re: Portlet related issues

2009-01-23 Thread German Morales
Well, i haven't tried but from what i see the images suggestion should
work...

By the way, i see that there is a chance of conflict between our CSSs and
the ones of the portal, and other portlets.

I'm understanding now that it's not that simple to take a working wicket
application and deploying it as a portlet.
Is there anything else we should consider?
(I'm having some trouble with some javascript too, i didn't have time to
check the reason yet).

Additionally, how do i get access to portal services like single sing-on?

Thanks for the help,

German

2009/1/22 German Morales germanamora...@gmail.com

 Hi Serkan,

 Thanks for the answer, i will give it a try and post the results later

 German

 2009/1/22 Serkan Camurcuoglu serkan.camurcuo...@telenity.com

 1. To overcome this problem in my application I put my css and image files
 into the jetspeed layout template directory, for example
 /jetspeed/decorations/layout/tigris/css/styles.css and modified the template
 velocity file to include my css file.

 2. I think that's normal, and I think it would be impossible to confine
 the modal window within your portlet div since it's on a different z-index.
 If you want it to look better, you can try to style the modal window to
 better suit your portal page.

 hope this helps..

 SerkanC





 German Morales wrote:

 Hi all,

 I'm trying to run an existing wicket application as a Portlet.
 I've chosen Jetspeed-2, because it's Apache too, and i've also read in
 the
 list that people working in the Portlet support also work in Jetspeed
 development.

 I've got some success, specially following this HowTo:
 http://cwiki.apache.org/WICKET/portal-howto.html

 After some effort, my application is basically running.
 However, i'm having trouble with some issues:

 1. CSS references to images (as div backgrounds).
   I've read in some forums and it seems to be generic problem in portals.
   CSS have URLs to images, which the portal does not transform to provide
 a
 redirection.
   The browser, then asks for the images to the portal server directly, no
 redirection is done to the portlet application.
   Any tips on how to solve this?
   (there seems to be a workaround for WebLogic portal:
 http://www.gexperts.com/blog/archives/2007/12/entry_20.html)

 2. ModalWindow
   ModalWindow works by hanging (with javascript) a new div from the body
 of
 the current document.
   This works wonderful when Wicket is the owner of the page.
   However, the application is now inside a portlet window, not in the
 whole page.
   When ModalWindow hangs from the page as usual, it looks odd... it's
 outside the portlet window.
   Any ideas?

 Thanks in advance,

 German





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





Re: different modal windows from same link or just multiple links?

2009-01-23 Thread German Morales
Hi Steve,

Excuse me if i'm missing something...

Shouldn't you just provide different panels to the window, depending on your
condition?
That is, inside your onClick(), calling setContent(new YourPanel());

On the code you show, i don't see where you set the content to the window...
are you doing it in advance? (that could be a bad idea).

Regards,

German


2009/1/23 Steve Swinsburg s.swinsb...@lancaster.ac.uk

 Hi all,
 I have a situation where depending on some circumstances, any one of three
 different modal windows could be activated by clicking a single link, which
 itself changes.

 ie add/confirm/remove

 but only one can be visible at any one time. I don't want three links. Is
 there any way to do this by setting the onClick handler of the AjaxLink that
 normally just contains:
 final AjaxLink connectionLink = new AjaxLink(connectionLink) {
 public void onClick(AjaxRequestTarget target) {
  connectionWindow.show(target);
 }
 };

 to be dynamically set, ie connectionWindow.show(target); is set at a later
 stage.

 Or will I just need multiple modal window placeholders and multiple links
 and just show/hide the relevant ones?

 I would also need the connectionWindow.setWindowClosedCallback
 to react differently based on which modal window was closed.

 Is there any point in what I am trying to do or should I just suck it up
 and have three links/windows and control visibility? Will I achieve any
 major performance hits by tripling everything?


 cheers,
 Steve









Portlet related issues

2009-01-22 Thread German Morales
Hi all,

I'm trying to run an existing wicket application as a Portlet.
I've chosen Jetspeed-2, because it's Apache too, and i've also read in the
list that people working in the Portlet support also work in Jetspeed
development.

I've got some success, specially following this HowTo:
http://cwiki.apache.org/WICKET/portal-howto.html

After some effort, my application is basically running.
However, i'm having trouble with some issues:

1. CSS references to images (as div backgrounds).
   I've read in some forums and it seems to be generic problem in portals.
   CSS have URLs to images, which the portal does not transform to provide a
redirection.
   The browser, then asks for the images to the portal server directly, no
redirection is done to the portlet application.
   Any tips on how to solve this?
   (there seems to be a workaround for WebLogic portal:
http://www.gexperts.com/blog/archives/2007/12/entry_20.html)

2. ModalWindow
   ModalWindow works by hanging (with javascript) a new div from the body of
the current document.
   This works wonderful when Wicket is the owner of the page.
   However, the application is now inside a portlet window, not in the
whole page.
   When ModalWindow hangs from the page as usual, it looks odd... it's
outside the portlet window.
   Any ideas?

Thanks in advance,

German


Re: Portlet related issues

2009-01-22 Thread German Morales
Hi Serkan,

Thanks for the answer, i will give it a try and post the results later

German

2009/1/22 Serkan Camurcuoglu serkan.camurcuo...@telenity.com

 1. To overcome this problem in my application I put my css and image files
 into the jetspeed layout template directory, for example
 /jetspeed/decorations/layout/tigris/css/styles.css and modified the template
 velocity file to include my css file.

 2. I think that's normal, and I think it would be impossible to confine the
 modal window within your portlet div since it's on a different z-index. If
 you want it to look better, you can try to style the modal window to better
 suit your portal page.

 hope this helps..

 SerkanC





 German Morales wrote:

 Hi all,

 I'm trying to run an existing wicket application as a Portlet.
 I've chosen Jetspeed-2, because it's Apache too, and i've also read in the
 list that people working in the Portlet support also work in Jetspeed
 development.

 I've got some success, specially following this HowTo:
 http://cwiki.apache.org/WICKET/portal-howto.html

 After some effort, my application is basically running.
 However, i'm having trouble with some issues:

 1. CSS references to images (as div backgrounds).
   I've read in some forums and it seems to be generic problem in portals.
   CSS have URLs to images, which the portal does not transform to provide
 a
 redirection.
   The browser, then asks for the images to the portal server directly, no
 redirection is done to the portlet application.
   Any tips on how to solve this?
   (there seems to be a workaround for WebLogic portal:
 http://www.gexperts.com/blog/archives/2007/12/entry_20.html)

 2. ModalWindow
   ModalWindow works by hanging (with javascript) a new div from the body
 of
 the current document.
   This works wonderful when Wicket is the owner of the page.
   However, the application is now inside a portlet window, not in the
 whole page.
   When ModalWindow hangs from the page as usual, it looks odd... it's
 outside the portlet window.
   Any ideas?

 Thanks in advance,

 German





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




Re: Automated testing of Wicket applications

2008-09-12 Thread German Morales
Hi Jan,

We are using Watir, which lets you write tests in ruby.

And we are using mainly wicket generated names for identification of
components, but sometimes we use generated attributes too (for example a
does not have name), or just the text in the html.

Since the code is all in ruby, it is in theory easy to refactor in case of
some changes.
For example, you can do this:

   textfield = ie.text_field(:name, your:very:long:wicket:generated:name)

or, in case of page changes...

   constant_defined_somewhere = your:very:long:wicket
   textfield = ie.text_field(:name, constant_defined_somewhere +
:generated:name)

then you could fix all tests just changing the constant.
Well, this is an explanation of a quick solution to your particular case of
changing the hierarchy.
But the idea is that you have a full (and good) programming language to do
things right: refactoring, reuse, and so on.

Beware:
Watir does not always runs perfectly... the tests are somehow dependent on
timing, which depends on the machine you run the tests, and other factors.
This is specially problematic in ajax calls.
That means that sometimes we get errors, then we run the same test again and
it works.

Hope this helps,

German

2008/9/12 Jan Stette [EMAIL PROTECTED]

 This is a bit of a general question: I'd be interested in hearing about how
 people do automated tests of their Wicket applications.  I'm thinking about
 system tests of the full application, not unit tests.

 There are of course tools like Selenium which let you automate actions on a
 web application.  My colleagues with experience of this from other
 applications tell me that one of the main challenges is to stop test cases
 from being very brittle by relying on the details of the generated markup.
 It would be nice if it was possible to target components on a page in a way
 that related them back to roughly the hierarchy of Wicket components.  Or
 even better, if individual parts of the page (links, input fields, buttons
 etc.) could be identified in a way that didn't break when there were
 changes
 to the Wicket component hierarchy (say, new grouping components being
 inserted higher up in the component tree).

 I realise this isn't the responsibility of Wicket, but are there ways in
 which Wicket can help here, e.g. by generating ids or other attributes
 inside the markup in a way that makes it easier to locate items on a page?
 Are there other tools than Selenium that people use, that makes things
 easier?

 I'm looking forward to hearing about how other Wicket users deal with these
 issues!

 Regards,
 Jan



Re: Automated testing of Wicket applications

2008-09-12 Thread German Morales
Actually there are more platforms for watir (
http://wtr.rubyforge.org/platforms.html): FireWatir and SafariWatir.

I gave a quick try to FireWatir some time ago, with no much success, but
they continue working on it.

They mention also a Watir interface that uses Selenium.


2008/9/12 Peter Thomas [EMAIL PROTECTED]

 On Fri, Sep 12, 2008 at 8:12 PM, German Morales [EMAIL PROTECTED]
wrote:

  Hi Jan,
 
  We are using Watir, which lets you write tests in ruby.
 

 For those who don't want to use Ruby, Watij is the Java equivalent of
 Watir.  http://watij.com/

 But the problem with both Watij and Watir is that you have to use
Microsoft
 Internet Explorer.  FireFox is not supported.

 I use Selenium-RC with JUnit, works fine for me.  I wrote some code to run
 JUnit test methods in guranteed order for functional tests and also
 clickAndWait.

 About the problem of tests being brittle and being able to use the Wicket
 id-s etc. you can look at this wiki page on JMeter and Wicket:


http://cwiki.apache.org/WICKET/wicket-and-jmeter-with-regular-expressions.html

 I haven't tried but maybe you can apply some of the ideas there to
Selenium
 tests.  So if you know the wicket:id beforehand, you could possibly access
 the component you need.

 - Peter.

 And we are using mainly wicket generated names for identification of
  components, but sometimes we use generated attributes too (for example
a
  does not have name), or just the text in the html.
 
  Since the code is all in ruby, it is in theory easy to refactor in case
of
  some changes.
  For example, you can do this:
 
textfield = ie.text_field(:name,
your:very:long:wicket:generated:name)
 
  or, in case of page changes...
 
constant_defined_somewhere = your:very:long:wicket
textfield = ie.text_field(:name, constant_defined_somewhere +
  :generated:name)
 
  then you could fix all tests just changing the constant.
  Well, this is an explanation of a quick solution to your particular case
of
  changing the hierarchy.
  But the idea is that you have a full (and good) programming language to
do
  things right: refactoring, reuse, and so on.
 
  Beware:
  Watir does not always runs perfectly... the tests are somehow dependent
on
  timing, which depends on the machine you run the tests, and other
factors.
  This is specially problematic in ajax calls.
  That means that sometimes we get errors, then we run the same test again
  and
  it works.
 
  Hope this helps,
 
  German
 
  2008/9/12 Jan Stette [EMAIL PROTECTED]
 
   This is a bit of a general question: I'd be interested in hearing
about
  how
   people do automated tests of their Wicket applications.  I'm thinking
  about
   system tests of the full application, not unit tests.
  
   There are of course tools like Selenium which let you automate actions
on
  a
   web application.  My colleagues with experience of this from other
   applications tell me that one of the main challenges is to stop test
  cases
   from being very brittle by relying on the details of the generated
  markup.
   It would be nice if it was possible to target components on a page in
a
  way
   that related them back to roughly the hierarchy of Wicket components.
 Or
   even better, if individual parts of the page (links, input fields,
  buttons
   etc.) could be identified in a way that didn't break when there were
   changes
   to the Wicket component hierarchy (say, new grouping components being
   inserted higher up in the component tree).
  
   I realise this isn't the responsibility of Wicket, but are there ways
in
   which Wicket can help here, e.g. by generating ids or other attributes
   inside the markup in a way that makes it easier to locate items on a
  page?
   Are there other tools than Selenium that people use, that makes things
   easier?
  
   I'm looking forward to hearing about how other Wicket users deal with
  these
   issues!
  
   Regards,
   Jan
  
 


Re: Automated testing of Wicket applications

2008-09-12 Thread German Morales
2008/9/12 Jan Stette [EMAIL PROTECTED]

 Hi German, thanks for an interesting reply.

 Ruby probably wouldn't be appropriate in our environment, but it's still
 interesting to see the principles involved in writing tests using it.  Some
 points I'm not clear about:

 When Wicket generates pages, as far as I can tell, the wicket:id that's
 stated in the markup just shows the local wicket:id, not the full path.  So
 how can you refer to the item by the whole path, as in your example?  (Is
 there a way to change which ids are rendered in the markup?)


Yes, the wicket id is not usable to search the components, because wicket
adds some extra characters in runtime.

Normally, the name attribute should be good enough, and that's what we are
using.

From FormComponent#getInputName:
/**
 * Gets the string to be used for the name attribute of the form
element. Generated
 * using the path from the form to the component, excluding the form
itself. ...
 * ...
 */

You should see attributes generated like:
   panel1:panel2:form:panel3:innerForm:whateverElse:YourComponentID

I'm also interested in what you say about using generated attributes.  One
 of the problems we're facing is that our application is highly dynamic, the
 exact structure of a page depends on user configuration and setup.  So I
 was
 thinking about something like using AttributeModifiers to set known ids on
 certain key components on a page.  Is this what you mean by generated
 attributes?


Yes, that's a possible way. Also i was mentioning it for components that do
not have a name, like Links.
They are not FormComponents, but you still want to find them.


 Then, to make it all more interesting, there's Ajax.  Our application makes
 heavy use of Ajax, so components come and go on a page in response to Ajax
 updates.  I'm not sure which ids are available for identifying components
 in
 this case.  Looking at pages in FireBug, I can't see wicket:id tags at all,
 but I'm not sure if that's missing something...  Is this something you have
 dealt with in your testing?



 Regards,
 Jan


 2008/9/12 German Morales [EMAIL PROTECTED]

  Hi Jan,
 
  We are using Watir, which lets you write tests in ruby.
 
  And we are using mainly wicket generated names for identification of
  components, but sometimes we use generated attributes too (for example
 a
  does not have name), or just the text in the html.
 
  Since the code is all in ruby, it is in theory easy to refactor in case
 of
  some changes.
  For example, you can do this:
 
textfield = ie.text_field(:name,
 your:very:long:wicket:generated:name)
 
  or, in case of page changes...
 
constant_defined_somewhere = your:very:long:wicket
textfield = ie.text_field(:name, constant_defined_somewhere +
  :generated:name)
 
  then you could fix all tests just changing the constant.
  Well, this is an explanation of a quick solution to your particular case
 of
  changing the hierarchy.
  But the idea is that you have a full (and good) programming language to
 do
  things right: refactoring, reuse, and so on.
 
  Beware:
  Watir does not always runs perfectly... the tests are somehow dependent
 on
  timing, which depends on the machine you run the tests, and other
 factors.
  This is specially problematic in ajax calls.
  That means that sometimes we get errors, then we run the same test again
  and
  it works.
 
  Hope this helps,
 
  German
 
  2008/9/12 Jan Stette [EMAIL PROTECTED]
 
   This is a bit of a general question: I'd be interested in hearing about
  how
   people do automated tests of their Wicket applications.  I'm thinking
  about
   system tests of the full application, not unit tests.
  
   There are of course tools like Selenium which let you automate actions
 on
  a
   web application.  My colleagues with experience of this from other
   applications tell me that one of the main challenges is to stop test
  cases
   from being very brittle by relying on the details of the generated
  markup.
   It would be nice if it was possible to target components on a page in a
  way
   that related them back to roughly the hierarchy of Wicket components.
  Or
   even better, if individual parts of the page (links, input fields,
  buttons
   etc.) could be identified in a way that didn't break when there were
   changes
   to the Wicket component hierarchy (say, new grouping components being
   inserted higher up in the component tree).
  
   I realise this isn't the responsibility of Wicket, but are there ways
 in
   which Wicket can help here, e.g. by generating ids or other attributes
   inside the markup in a way that makes it easier to locate items on a
  page?
   Are there other tools than Selenium that people use, that makes things
   easier?
  
   I'm looking forward to hearing about how other Wicket users deal with
  these
   issues!
  
   Regards,
   Jan
  
 



Re: Form values lost in combination of Forms plus ModalWindow

2008-09-11 Thread German Morales
Hi again,

jira issue added:
   https://issues.apache.org/jira/browse/WICKET-1826

I've attached a quickstart project which shows my problem, has detailed
explanation, and also proposes 2 solutions (you must uncomment some code to
see it working). Of course, the solutions work for my particular case, but
as you told me, it is not the way it is supposed to be.

Meanwhile (i guess it can take a while until someone looks into it), could
you at least tell me if there could be any side effect in overriding
isInputNullable for CheckBox, DropDownChoice, and so on? (TextField already
does it).

Thanks again,

German


2008/9/10 Matej Knopp [EMAIL PROTECTED]

 On Wed, Sep 10, 2008 at 10:49 PM, German Morales
 [EMAIL PROTECTED] wrote:
  I don't see any div inside span in my stuff (we have suffered problems
 with
  this long ago, and we are more careful lately).
 
  Besides that, is it ok that the ModalWindow creates its own div at body
  level? Isn't that the reason of my problem?
 That is intentional. I don't think that should cause you the problems.

 -Matej
 
  German
 
  2008/9/10 Matej Knopp [EMAIL PROTECTED]
 
  Check if your DOM hierarchy is valid, e.g. if you don't have any div
  tag inside span tags.
 
  -Matej
 
  On Wed, Sep 10, 2008 at 10:08 PM, German Morales
  [EMAIL PROTECTED] wrote:
   I think that we are closer to the problem now...
  
   In my case (going back to the original post), the form i'm submitting
 is
   inside a ModalWindow.
  
   I'm using Firebug to see the generated DOM in runtime, and i find this
   (extracted...) before calling the ModalWindow:
  
   body
 div here is all my content, even the placeholder for the modal
 window
form here is my root form
 /div
 div added by wicket for the ajax debug window
   /body
  
   after calling the modal window:
  
   body
 div here is all my content, even the placeholder for the modal
 window
form here is my root form
 /div
 div added by wicket for the ajax debug window
 div added by modal window on the fly
form a second form tag for the form in my modal window
 /div
   /body
  
   I think that it's ok that the second form is rendered as form, since
 it
  does
   not have another form outside (to be rendered as div).
   The problem is that ModalWindow inserted a div outside my root form.
   Therefore Wicket.Form.serialize() must be serializing up to that
 second
   form.
  
   I'm looking at the live Modal window example
   http://www.wicket-library.com/wicket-examples/ajax/modal-window.1
   and i see that this behavior of adding a separated div at body level
 is
   normal, not something strange in my structure.
  
   German
  
   2008/9/10 Matej Knopp [EMAIL PROTECTED]
  
   You are right. It calls Wicket.Form.serialize(form) with the nested
   form, but the serialize method should find parent with form tag
 name
   and serialize that.
  
   -Matej
  
  
   On Wed, Sep 10, 2008 at 9:04 PM, German Morales
   [EMAIL PROTECTED] wrote:
There are no nested form tags, as expected... let me give you more
   details
i'm discovering:
   
The AjaxSubmitLink has something like this...
 function onclick(event) {
  var wcall = wicketSubmitFormById(  id of my nested form  );
  return false;
 }
   
This calls wicketSubmitFormById, no surprises...
 function wicketSubmitFormById(formId, url, submitButton,
  successHandler,
failureHandler, precondition, channel) {
  var call = new Wicket.Ajax.Call(url, successHandler,
 failureHandler,
channel);
  ...
  return call.submitFormById(formId, submitButton);
 }
   
which calls submitFormById...
 submitFormById: function(formId, submitButton) {
  var form = Wicket.$(formId);
  ...
  return this.submitForm(form, submitButton);
 }
   
which calls submitForm passing my nested form (i'm debugging with
   Firebug)
 // Submits a form using ajax.
 // This method serializes a form and sends it as POST body.
 submitForm: function(form, submitButton) {
  var body = function() {
var s = Wicket.Form.serialize(form);
if (submitButton != null) {
  s += Wicket.Form.encode(submitButton) + =1;
}
return s;
  }
  return this.request.post(body);
 }
   
which ultimately calls Wicket.Form.serialize(form) with my nested
  form,
   not
with the root form.
   
Am i right?
   
German
   
PS: meanwhile i'm trying to produce a quickstart... but i guess it
  will
   take
me some time.
2008/9/10 Matej Knopp [EMAIL PROTECTED]
   
But that is exactly what should happen. Wicket javascript should
 find
root form element and serialize that. Can you please check in your
markup if there are any nested form tags? (shouldn't be).
   
-Matej
   
On Wed, Sep 10, 2008 at 8:11 PM, German Morales
[EMAIL PROTECTED] wrote:
 That would be somehow complicated to produce right now.

 To make my

Re: Form values lost in combination of Forms plus ModalWindow

2008-09-10 Thread German Morales
Investigating a little more, my problem seems to be caused by
AjaxFormSubmitBehavior#onEvent

protected void onEvent(AjaxRequestTarget target) {
getForm().getRootForm().onFormSubmitted();

which calls onFormSubmitted on the RootForm, and not in the Form i've passed
to my AjaxSubmitLink.

could someone explain me why it does that?

In fact, overriding onEvent to call onFormSubmitted on getForm() and not in
the root form solves my problems... but am i breaking something else?

Thanks,

German


2008/9/9 German Morales [EMAIL PROTECTED]

 Hi Matej,

 Thanks for the answer.

 I have an AjaxSubmitLink both for opening and closing the modal window.
 Should that make any trouble?
 In both cases i have data to persist, so it must be a .*Submit.* component.

 Also, my problem happens when closing the window, not when opening it.
 I summarize it again:
 -the browser sends an ajax call with the values in the modal window
 -but on wicket side the main form of the page is the one that takes charge
 -the components on the page then receive the new input, but there's
 actually nothing coming from the browser for them
 -some components (text components) handle it well, some not (checkbox,
 dropdownchoice).
 -the misbehaving component get a rawinput of null instead of NO_RAW_INPUT,
 which then produces the side effect that the component does not get the
 value from the model on rendering.

 Please see the doubts section at the end of the original e-mail.

 Thanks again,

 German

 2008/9/9 Matej Knopp [EMAIL PROTECTED]

 The link that shows the modal window must be AjaxButton/SubmitLink.

 -Matej

 On Tue, Sep 9, 2008 at 11:20 PM, German Morales
 [EMAIL PROTECTED] wrote:
  Hi all,
 
  I've a problem with Forms and ModalWindows.
 
  I have this stuff:
  -a page with a main Form (the only one that is rendered as an HTML form
 tag)
  -this my only page, since all inside it is changed by replacing panels
 using
  ajax.
  -inside some other levels of panels, i have a panel with my content (let
 me
  call it myContentPanel), which has its own (sub) Form (which is rendered
 as
  a div).
  -myContentPanel has some controls... TextFields, DropDownChoices,
  CheckBoxes.
  -myContentPanel has also a link that opens a ModalWindow.
  -the ModalWindow has its own Form with components, and an AjaxSubmitLink
 to
  close it.
 
  Now the problem...
  1- I enter to myContentPanel and enter some values in the components.
  2- I press the link to open the ModalWindow.
  3- I work with the ModalWindow, then press an AjaxSubmitLink to close
 it.
  4- When refreshing myContentPanel, the values in some controls is lost:
  CheckBoxes, DropDownChoices, but NOT in TextFields.
 
  After some investigation, this is what i've discovered:
  -on step 3 (accept and close the ModalWindow), the AjaxSubmitLink calls
  (javascript) wicketSubmitFormById passing the ModalWindow's form as
  parameter.
  -this processes the ModalWindow's form and prepares the values to be
 sent to
  wicket side.
  -but when i see the url, it mentions that the form that will be used for
 the
  HTTP request is the page's form (because it's the only real form, i
 think
  this is normal).
  -on wicket side, the request processing calls Form#onFormSubmitted,
 which
  calls #inputChanged, which calls a visitor visiting all components... in
 the
  main form!
  -this ends up calling FormComponent#inputChanged on the CheckBoxes,
  DropDownChoices, TextFields that where in myContentPanel (also for the
  controls in the ModalWindow, but that's no surprise).
  -given that the javascript only prepared the data for the ModalWindow's
  form, the values for the components in myContentPanel is empty.
  -looking deeper in #inputChanged, getInputAsArray() gives null for the
  components in myContentPanel.
  -then, since CheckBox and DropDownChoice answer true to
 isInputNullable()
  (default in FormComponent), the rawInput is set to null, even if i
 didn't
  touch the CheckBoxes/DropDownChoices at all in this call (then losing
 the
  previous value: NO_RAW_INPUT).
  -on step 4, when the CheckBox/DropDownChoice wants to get rendered
 again,
  onComponentTag calls FormComponent#getValue, which if
  (NO_RAW_INPUT.equals(rawInput)) uses the Model to get the value (what i
  would expect), but in my case returns the rawInput (null... ouch).
 
  I have fixed it temporaly by overriding isInputNullable in my
  CheckBoxes/DropDownChoice, but i understand that this is not a very good
  solution.
 
  Some doubts that remain:
  -is there anything wrong with my structure of forms and panels, which is
  actually producing these side effects?
  -if only the values for ModalWindow form are sent to the server, why the
 is
  onFormSubmitted called on the main page form?
  -the javadoc in isInputNullable is not very clear for me... do i break
  something else if i override isInputNullable answering false?
 
  Thanks in advance,
 
  German

Re: Form values lost in combination of Forms plus ModalWindow

2008-09-10 Thread German Morales
That would be somehow complicated to produce right now.

To make my question different... why the javascript side sends only the
nested form info (wicketSubmitFormById()) and on wicket side the root form
is the one that gets called?

I've already tried and it works ok if i make the nested form do the
processing instead of the root form.
protected void onEvent(AjaxRequestTarget target) {
getForm().onFormSubmitted();  // getRootForm() removed

Another possibility would be that javascript side sends the values for the
root form, and then it would be ok that the root form does the processing.

Thanks,

German


2008/9/10 Matej Knopp [EMAIL PROTECTED]

 I would need a quick start to see where it is going wrong.

 -Matej

 On Wed, Sep 10, 2008 at 7:26 PM, German Morales
 [EMAIL PROTECTED] wrote:
  Investigating a little more, my problem seems to be caused by
  AjaxFormSubmitBehavior#onEvent
 
 protected void onEvent(AjaxRequestTarget target) {
 getForm().getRootForm().onFormSubmitted();
 
  which calls onFormSubmitted on the RootForm, and not in the Form i've
 passed
  to my AjaxSubmitLink.
 
  could someone explain me why it does that?
 
  In fact, overriding onEvent to call onFormSubmitted on getForm() and not
 in
  the root form solves my problems... but am i breaking something else?
 
  Thanks,
 
  German
 
 
  2008/9/9 German Morales [EMAIL PROTECTED]
 
  Hi Matej,
 
  Thanks for the answer.
 
  I have an AjaxSubmitLink both for opening and closing the modal window.
  Should that make any trouble?
  In both cases i have data to persist, so it must be a .*Submit.*
 component.
 
  Also, my problem happens when closing the window, not when opening it.
  I summarize it again:
  -the browser sends an ajax call with the values in the modal window
  -but on wicket side the main form of the page is the one that takes
 charge
  -the components on the page then receive the new input, but there's
  actually nothing coming from the browser for them
  -some components (text components) handle it well, some not (checkbox,
  dropdownchoice).
  -the misbehaving component get a rawinput of null instead of
 NO_RAW_INPUT,
  which then produces the side effect that the component does not get the
  value from the model on rendering.
 
  Please see the doubts section at the end of the original e-mail.
 
  Thanks again,
 
  German
 
  2008/9/9 Matej Knopp [EMAIL PROTECTED]
 
  The link that shows the modal window must be AjaxButton/SubmitLink.
 
  -Matej
 
  On Tue, Sep 9, 2008 at 11:20 PM, German Morales
  [EMAIL PROTECTED] wrote:
   Hi all,
  
   I've a problem with Forms and ModalWindows.
  
   I have this stuff:
   -a page with a main Form (the only one that is rendered as an HTML
 form
  tag)
   -this my only page, since all inside it is changed by replacing
 panels
  using
   ajax.
   -inside some other levels of panels, i have a panel with my content
 (let
  me
   call it myContentPanel), which has its own (sub) Form (which is
 rendered
  as
   a div).
   -myContentPanel has some controls... TextFields, DropDownChoices,
   CheckBoxes.
   -myContentPanel has also a link that opens a ModalWindow.
   -the ModalWindow has its own Form with components, and an
 AjaxSubmitLink
  to
   close it.
  
   Now the problem...
   1- I enter to myContentPanel and enter some values in the components.
   2- I press the link to open the ModalWindow.
   3- I work with the ModalWindow, then press an AjaxSubmitLink to close
  it.
   4- When refreshing myContentPanel, the values in some controls is
 lost:
   CheckBoxes, DropDownChoices, but NOT in TextFields.
  
   After some investigation, this is what i've discovered:
   -on step 3 (accept and close the ModalWindow), the AjaxSubmitLink
 calls
   (javascript) wicketSubmitFormById passing the ModalWindow's form as
   parameter.
   -this processes the ModalWindow's form and prepares the values to be
  sent to
   wicket side.
   -but when i see the url, it mentions that the form that will be used
 for
  the
   HTTP request is the page's form (because it's the only real form, i
  think
   this is normal).
   -on wicket side, the request processing calls Form#onFormSubmitted,
  which
   calls #inputChanged, which calls a visitor visiting all components...
 in
  the
   main form!
   -this ends up calling FormComponent#inputChanged on the CheckBoxes,
   DropDownChoices, TextFields that where in myContentPanel (also for
 the
   controls in the ModalWindow, but that's no surprise).
   -given that the javascript only prepared the data for the
 ModalWindow's
   form, the values for the components in myContentPanel is empty.
   -looking deeper in #inputChanged, getInputAsArray() gives null for
 the
   components in myContentPanel.
   -then, since CheckBox and DropDownChoice answer true to
  isInputNullable()
   (default in FormComponent), the rawInput is set to null, even if i
  didn't
   touch the CheckBoxes/DropDownChoices at all in this call (then losing
  the
   previous value

Re: Form values lost in combination of Forms plus ModalWindow

2008-09-10 Thread German Morales
There are no nested form tags, as expected... let me give you more details
i'm discovering:

The AjaxSubmitLink has something like this...
 function onclick(event) {
   var wcall = wicketSubmitFormById(  id of my nested form  );
   return false;
 }

This calls wicketSubmitFormById, no surprises...
 function wicketSubmitFormById(formId, url, submitButton, successHandler,
failureHandler, precondition, channel) {
   var call = new Wicket.Ajax.Call(url, successHandler, failureHandler,
channel);
   ...
   return call.submitFormById(formId, submitButton);
 }

which calls submitFormById...
 submitFormById: function(formId, submitButton) {
   var form = Wicket.$(formId);
   ...
   return this.submitForm(form, submitButton);
 }

which calls submitForm passing my nested form (i'm debugging with Firebug)
 // Submits a form using ajax.
 // This method serializes a form and sends it as POST body.
 submitForm: function(form, submitButton) {
   var body = function() {
 var s = Wicket.Form.serialize(form);
 if (submitButton != null) {
   s += Wicket.Form.encode(submitButton) + =1;
 }
 return s;
   }
   return this.request.post(body);
 }

which ultimately calls Wicket.Form.serialize(form) with my nested form, not
with the root form.

Am i right?

German

PS: meanwhile i'm trying to produce a quickstart... but i guess it will take
me some time.
2008/9/10 Matej Knopp [EMAIL PROTECTED]

 But that is exactly what should happen. Wicket javascript should find
 root form element and serialize that. Can you please check in your
 markup if there are any nested form tags? (shouldn't be).

 -Matej

 On Wed, Sep 10, 2008 at 8:11 PM, German Morales
 [EMAIL PROTECTED] wrote:
  That would be somehow complicated to produce right now.
 
  To make my question different... why the javascript side sends only the
  nested form info (wicketSubmitFormById()) and on wicket side the root
 form
  is the one that gets called?
 
  I've already tried and it works ok if i make the nested form do the
  processing instead of the root form.
 protected void onEvent(AjaxRequestTarget target) {
 getForm().onFormSubmitted();  // getRootForm() removed
 
  Another possibility would be that javascript side sends the values for
 the
  root form, and then it would be ok that the root form does the
 processing.
 
  Thanks,
 
  German
 
 
  2008/9/10 Matej Knopp [EMAIL PROTECTED]
 
  I would need a quick start to see where it is going wrong.
 
  -Matej
 
  On Wed, Sep 10, 2008 at 7:26 PM, German Morales
  [EMAIL PROTECTED] wrote:
   Investigating a little more, my problem seems to be caused by
   AjaxFormSubmitBehavior#onEvent
  
  protected void onEvent(AjaxRequestTarget target) {
  getForm().getRootForm().onFormSubmitted();
  
   which calls onFormSubmitted on the RootForm, and not in the Form i've
  passed
   to my AjaxSubmitLink.
  
   could someone explain me why it does that?
  
   In fact, overriding onEvent to call onFormSubmitted on getForm() and
 not
  in
   the root form solves my problems... but am i breaking something else?
  
   Thanks,
  
   German
  
  
   2008/9/9 German Morales [EMAIL PROTECTED]
  
   Hi Matej,
  
   Thanks for the answer.
  
   I have an AjaxSubmitLink both for opening and closing the modal
 window.
   Should that make any trouble?
   In both cases i have data to persist, so it must be a .*Submit.*
  component.
  
   Also, my problem happens when closing the window, not when opening
 it.
   I summarize it again:
   -the browser sends an ajax call with the values in the modal window
   -but on wicket side the main form of the page is the one that takes
  charge
   -the components on the page then receive the new input, but there's
   actually nothing coming from the browser for them
   -some components (text components) handle it well, some not
 (checkbox,
   dropdownchoice).
   -the misbehaving component get a rawinput of null instead of
  NO_RAW_INPUT,
   which then produces the side effect that the component does not get
 the
   value from the model on rendering.
  
   Please see the doubts section at the end of the original e-mail.
  
   Thanks again,
  
   German
  
   2008/9/9 Matej Knopp [EMAIL PROTECTED]
  
   The link that shows the modal window must be AjaxButton/SubmitLink.
  
   -Matej
  
   On Tue, Sep 9, 2008 at 11:20 PM, German Morales
   [EMAIL PROTECTED] wrote:
Hi all,
   
I've a problem with Forms and ModalWindows.
   
I have this stuff:
-a page with a main Form (the only one that is rendered as an HTML
  form
   tag)
-this my only page, since all inside it is changed by replacing
  panels
   using
ajax.
-inside some other levels of panels, i have a panel with my
 content
  (let
   me
call it myContentPanel), which has its own (sub) Form (which is
  rendered
   as
a div).
-myContentPanel has some controls... TextFields, DropDownChoices,
CheckBoxes.
-myContentPanel has also a link that opens a ModalWindow

Re: Form values lost in combination of Forms plus ModalWindow

2008-09-10 Thread German Morales
I'm also reading this...
http://cwiki.apache.org/WICKET/nested-forms.html
which in the case of all forms enabled, inner form submitted (3rd row).

the result should be:


Outer: nothing called, but input is preserved

Middle: nothing called, but input is preserved

Inner: onSubmit called

So again, i come to think that onFormSubmitted should be called in the Form
i passed to my ajax submit link, not the root form.
But perhaps i'm missing something?

Thanks for the support,

German

2008/9/10 German Morales [EMAIL PROTECTED]

 There are no nested form tags, as expected... let me give you more details
 i'm discovering:

 The AjaxSubmitLink has something like this...
  function onclick(event) {
var wcall = wicketSubmitFormById(  id of my nested form  );
return false;
  }

 This calls wicketSubmitFormById, no surprises...
  function wicketSubmitFormById(formId, url, submitButton, successHandler,
 failureHandler, precondition, channel) {
var call = new Wicket.Ajax.Call(url, successHandler, failureHandler,
 channel);
...
return call.submitFormById(formId, submitButton);
  }

 which calls submitFormById...
  submitFormById: function(formId, submitButton) {
var form = Wicket.$(formId);
...
return this.submitForm(form, submitButton);
  }

 which calls submitForm passing my nested form (i'm debugging with Firebug)
  // Submits a form using ajax.
  // This method serializes a form and sends it as POST body.
  submitForm: function(form, submitButton) {
var body = function() {
  var s = Wicket.Form.serialize(form);
  if (submitButton != null) {
s += Wicket.Form.encode(submitButton) + =1;
  }
  return s;
}
return this.request.post(body);
  }

 which ultimately calls Wicket.Form.serialize(form) with my nested form, not
 with the root form.

 Am i right?

 German

 PS: meanwhile i'm trying to produce a quickstart... but i guess it will
 take me some time.

 2008/9/10 Matej Knopp [EMAIL PROTECTED]

 But that is exactly what should happen. Wicket javascript should find
 root form element and serialize that. Can you please check in your
 markup if there are any nested form tags? (shouldn't be).

 -Matej

 On Wed, Sep 10, 2008 at 8:11 PM, German Morales
 [EMAIL PROTECTED] wrote:
  That would be somehow complicated to produce right now.
 
  To make my question different... why the javascript side sends only the
  nested form info (wicketSubmitFormById()) and on wicket side the root
 form
  is the one that gets called?
 
  I've already tried and it works ok if i make the nested form do the
  processing instead of the root form.
 protected void onEvent(AjaxRequestTarget target) {
 getForm().onFormSubmitted();  // getRootForm() removed
 
  Another possibility would be that javascript side sends the values for
 the
  root form, and then it would be ok that the root form does the
 processing.
 
  Thanks,
 
  German
 
 
  2008/9/10 Matej Knopp [EMAIL PROTECTED]
 
  I would need a quick start to see where it is going wrong.
 
  -Matej
 
  On Wed, Sep 10, 2008 at 7:26 PM, German Morales
  [EMAIL PROTECTED] wrote:
   Investigating a little more, my problem seems to be caused by
   AjaxFormSubmitBehavior#onEvent
  
  protected void onEvent(AjaxRequestTarget target) {
  getForm().getRootForm().onFormSubmitted();
  
   which calls onFormSubmitted on the RootForm, and not in the Form i've
  passed
   to my AjaxSubmitLink.
  
   could someone explain me why it does that?
  
   In fact, overriding onEvent to call onFormSubmitted on getForm() and
 not
  in
   the root form solves my problems... but am i breaking something else?
  
   Thanks,
  
   German
  
  
   2008/9/9 German Morales [EMAIL PROTECTED]
  
   Hi Matej,
  
   Thanks for the answer.
  
   I have an AjaxSubmitLink both for opening and closing the modal
 window.
   Should that make any trouble?
   In both cases i have data to persist, so it must be a .*Submit.*
  component.
  
   Also, my problem happens when closing the window, not when opening
 it.
   I summarize it again:
   -the browser sends an ajax call with the values in the modal window
   -but on wicket side the main form of the page is the one that takes
  charge
   -the components on the page then receive the new input, but there's
   actually nothing coming from the browser for them
   -some components (text components) handle it well, some not
 (checkbox,
   dropdownchoice).
   -the misbehaving component get a rawinput of null instead of
  NO_RAW_INPUT,
   which then produces the side effect that the component does not get
 the
   value from the model on rendering.
  
   Please see the doubts section at the end of the original e-mail.
  
   Thanks again,
  
   German
  
   2008/9/9 Matej Knopp [EMAIL PROTECTED]
  
   The link that shows the modal window must be AjaxButton/SubmitLink.
  
   -Matej
  
   On Tue, Sep 9, 2008 at 11:20 PM, German Morales
   [EMAIL PROTECTED] wrote:
Hi all,
   
I've a problem with Forms

Re: Form values lost in combination of Forms plus ModalWindow

2008-09-10 Thread German Morales
I think that we are closer to the problem now...

In my case (going back to the original post), the form i'm submitting is
inside a ModalWindow.

I'm using Firebug to see the generated DOM in runtime, and i find this
(extracted...) before calling the ModalWindow:

body
   div here is all my content, even the placeholder for the modal window
  form here is my root form
   /div
   div added by wicket for the ajax debug window
/body

after calling the modal window:

body
   div here is all my content, even the placeholder for the modal window
  form here is my root form
   /div
   div added by wicket for the ajax debug window
   div added by modal window on the fly
  form a second form tag for the form in my modal window
   /div
/body

I think that it's ok that the second form is rendered as form, since it does
not have another form outside (to be rendered as div).
The problem is that ModalWindow inserted a div outside my root form.
Therefore Wicket.Form.serialize() must be serializing up to that second
form.

I'm looking at the live Modal window example
http://www.wicket-library.com/wicket-examples/ajax/modal-window.1
and i see that this behavior of adding a separated div at body level is
normal, not something strange in my structure.

German

2008/9/10 Matej Knopp [EMAIL PROTECTED]

 You are right. It calls Wicket.Form.serialize(form) with the nested
 form, but the serialize method should find parent with form tag name
 and serialize that.

 -Matej


 On Wed, Sep 10, 2008 at 9:04 PM, German Morales
 [EMAIL PROTECTED] wrote:
  There are no nested form tags, as expected... let me give you more
 details
  i'm discovering:
 
  The AjaxSubmitLink has something like this...
   function onclick(event) {
var wcall = wicketSubmitFormById(  id of my nested form  );
return false;
   }
 
  This calls wicketSubmitFormById, no surprises...
   function wicketSubmitFormById(formId, url, submitButton, successHandler,
  failureHandler, precondition, channel) {
var call = new Wicket.Ajax.Call(url, successHandler, failureHandler,
  channel);
...
return call.submitFormById(formId, submitButton);
   }
 
  which calls submitFormById...
   submitFormById: function(formId, submitButton) {
var form = Wicket.$(formId);
...
return this.submitForm(form, submitButton);
   }
 
  which calls submitForm passing my nested form (i'm debugging with
 Firebug)
   // Submits a form using ajax.
   // This method serializes a form and sends it as POST body.
   submitForm: function(form, submitButton) {
var body = function() {
  var s = Wicket.Form.serialize(form);
  if (submitButton != null) {
s += Wicket.Form.encode(submitButton) + =1;
  }
  return s;
}
return this.request.post(body);
   }
 
  which ultimately calls Wicket.Form.serialize(form) with my nested form,
 not
  with the root form.
 
  Am i right?
 
  German
 
  PS: meanwhile i'm trying to produce a quickstart... but i guess it will
 take
  me some time.
  2008/9/10 Matej Knopp [EMAIL PROTECTED]
 
  But that is exactly what should happen. Wicket javascript should find
  root form element and serialize that. Can you please check in your
  markup if there are any nested form tags? (shouldn't be).
 
  -Matej
 
  On Wed, Sep 10, 2008 at 8:11 PM, German Morales
  [EMAIL PROTECTED] wrote:
   That would be somehow complicated to produce right now.
  
   To make my question different... why the javascript side sends only
 the
   nested form info (wicketSubmitFormById()) and on wicket side the root
  form
   is the one that gets called?
  
   I've already tried and it works ok if i make the nested form do the
   processing instead of the root form.
  protected void onEvent(AjaxRequestTarget target) {
  getForm().onFormSubmitted();  // getRootForm() removed
  
   Another possibility would be that javascript side sends the values for
  the
   root form, and then it would be ok that the root form does the
  processing.
  
   Thanks,
  
   German
  
  
   2008/9/10 Matej Knopp [EMAIL PROTECTED]
  
   I would need a quick start to see where it is going wrong.
  
   -Matej
  
   On Wed, Sep 10, 2008 at 7:26 PM, German Morales
   [EMAIL PROTECTED] wrote:
Investigating a little more, my problem seems to be caused by
AjaxFormSubmitBehavior#onEvent
   
   protected void onEvent(AjaxRequestTarget target) {
   getForm().getRootForm().onFormSubmitted();
   
which calls onFormSubmitted on the RootForm, and not in the Form
 i've
   passed
to my AjaxSubmitLink.
   
could someone explain me why it does that?
   
In fact, overriding onEvent to call onFormSubmitted on getForm()
 and
  not
   in
the root form solves my problems... but am i breaking something
 else?
   
Thanks,
   
German
   
   
2008/9/9 German Morales [EMAIL PROTECTED]
   
Hi Matej,
   
Thanks for the answer.
   
I have an AjaxSubmitLink both for opening and closing the modal
  window

Re: Form values lost in combination of Forms plus ModalWindow

2008-09-10 Thread German Morales
I don't see any div inside span in my stuff (we have suffered problems with
this long ago, and we are more careful lately).

Besides that, is it ok that the ModalWindow creates its own div at body
level? Isn't that the reason of my problem?

German

2008/9/10 Matej Knopp [EMAIL PROTECTED]

 Check if your DOM hierarchy is valid, e.g. if you don't have any div
 tag inside span tags.

 -Matej

 On Wed, Sep 10, 2008 at 10:08 PM, German Morales
 [EMAIL PROTECTED] wrote:
  I think that we are closer to the problem now...
 
  In my case (going back to the original post), the form i'm submitting is
  inside a ModalWindow.
 
  I'm using Firebug to see the generated DOM in runtime, and i find this
  (extracted...) before calling the ModalWindow:
 
  body
div here is all my content, even the placeholder for the modal window
   form here is my root form
/div
div added by wicket for the ajax debug window
  /body
 
  after calling the modal window:
 
  body
div here is all my content, even the placeholder for the modal window
   form here is my root form
/div
div added by wicket for the ajax debug window
div added by modal window on the fly
   form a second form tag for the form in my modal window
/div
  /body
 
  I think that it's ok that the second form is rendered as form, since it
 does
  not have another form outside (to be rendered as div).
  The problem is that ModalWindow inserted a div outside my root form.
  Therefore Wicket.Form.serialize() must be serializing up to that second
  form.
 
  I'm looking at the live Modal window example
  http://www.wicket-library.com/wicket-examples/ajax/modal-window.1
  and i see that this behavior of adding a separated div at body level is
  normal, not something strange in my structure.
 
  German
 
  2008/9/10 Matej Knopp [EMAIL PROTECTED]
 
  You are right. It calls Wicket.Form.serialize(form) with the nested
  form, but the serialize method should find parent with form tag name
  and serialize that.
 
  -Matej
 
 
  On Wed, Sep 10, 2008 at 9:04 PM, German Morales
  [EMAIL PROTECTED] wrote:
   There are no nested form tags, as expected... let me give you more
  details
   i'm discovering:
  
   The AjaxSubmitLink has something like this...
function onclick(event) {
 var wcall = wicketSubmitFormById(  id of my nested form  );
 return false;
}
  
   This calls wicketSubmitFormById, no surprises...
function wicketSubmitFormById(formId, url, submitButton,
 successHandler,
   failureHandler, precondition, channel) {
 var call = new Wicket.Ajax.Call(url, successHandler, failureHandler,
   channel);
 ...
 return call.submitFormById(formId, submitButton);
}
  
   which calls submitFormById...
submitFormById: function(formId, submitButton) {
 var form = Wicket.$(formId);
 ...
 return this.submitForm(form, submitButton);
}
  
   which calls submitForm passing my nested form (i'm debugging with
  Firebug)
// Submits a form using ajax.
// This method serializes a form and sends it as POST body.
submitForm: function(form, submitButton) {
 var body = function() {
   var s = Wicket.Form.serialize(form);
   if (submitButton != null) {
 s += Wicket.Form.encode(submitButton) + =1;
   }
   return s;
 }
 return this.request.post(body);
}
  
   which ultimately calls Wicket.Form.serialize(form) with my nested
 form,
  not
   with the root form.
  
   Am i right?
  
   German
  
   PS: meanwhile i'm trying to produce a quickstart... but i guess it
 will
  take
   me some time.
   2008/9/10 Matej Knopp [EMAIL PROTECTED]
  
   But that is exactly what should happen. Wicket javascript should find
   root form element and serialize that. Can you please check in your
   markup if there are any nested form tags? (shouldn't be).
  
   -Matej
  
   On Wed, Sep 10, 2008 at 8:11 PM, German Morales
   [EMAIL PROTECTED] wrote:
That would be somehow complicated to produce right now.
   
To make my question different... why the javascript side sends only
  the
nested form info (wicketSubmitFormById()) and on wicket side the
 root
   form
is the one that gets called?
   
I've already tried and it works ok if i make the nested form do the
processing instead of the root form.
   protected void onEvent(AjaxRequestTarget target) {
   getForm().onFormSubmitted();  // getRootForm() removed
   
Another possibility would be that javascript side sends the values
 for
   the
root form, and then it would be ok that the root form does the
   processing.
   
Thanks,
   
German
   
   
2008/9/10 Matej Knopp [EMAIL PROTECTED]
   
I would need a quick start to see where it is going wrong.
   
-Matej
   
On Wed, Sep 10, 2008 at 7:26 PM, German Morales
[EMAIL PROTECTED] wrote:
 Investigating a little more, my problem seems to be caused by
 AjaxFormSubmitBehavior#onEvent

protected void

Re: Form values lost in combination of Forms plus ModalWindow

2008-09-10 Thread German Morales
I have a quickstart project, should i send it privately?

2008/9/10 German Morales [EMAIL PROTECTED]

 I don't see any div inside span in my stuff (we have suffered problems with
 this long ago, and we are more careful lately).

 Besides that, is it ok that the ModalWindow creates its own div at body
 level? Isn't that the reason of my problem?


 German

 2008/9/10 Matej Knopp [EMAIL PROTECTED]

 Check if your DOM hierarchy is valid, e.g. if you don't have any div
 tag inside span tags.

 -Matej

 On Wed, Sep 10, 2008 at 10:08 PM, German Morales
 [EMAIL PROTECTED] wrote:
  I think that we are closer to the problem now...
 
  In my case (going back to the original post), the form i'm submitting is
  inside a ModalWindow.
 
  I'm using Firebug to see the generated DOM in runtime, and i find this
  (extracted...) before calling the ModalWindow:
 
  body
div here is all my content, even the placeholder for the modal
 window
   form here is my root form
/div
div added by wicket for the ajax debug window
  /body
 
  after calling the modal window:
 
  body
div here is all my content, even the placeholder for the modal
 window
   form here is my root form
/div
div added by wicket for the ajax debug window
div added by modal window on the fly
   form a second form tag for the form in my modal window
/div
  /body
 
  I think that it's ok that the second form is rendered as form, since it
 does
  not have another form outside (to be rendered as div).
  The problem is that ModalWindow inserted a div outside my root form.
  Therefore Wicket.Form.serialize() must be serializing up to that second
  form.
 
  I'm looking at the live Modal window example
  http://www.wicket-library.com/wicket-examples/ajax/modal-window.1
  and i see that this behavior of adding a separated div at body level is
  normal, not something strange in my structure.
 
  German
 
  2008/9/10 Matej Knopp [EMAIL PROTECTED]
 
  You are right. It calls Wicket.Form.serialize(form) with the nested
  form, but the serialize method should find parent with form tag name
  and serialize that.
 
  -Matej
 
 
  On Wed, Sep 10, 2008 at 9:04 PM, German Morales
  [EMAIL PROTECTED] wrote:
   There are no nested form tags, as expected... let me give you more
  details
   i'm discovering:
  
   The AjaxSubmitLink has something like this...
function onclick(event) {
 var wcall = wicketSubmitFormById(  id of my nested form  );
 return false;
}
  
   This calls wicketSubmitFormById, no surprises...
function wicketSubmitFormById(formId, url, submitButton,
 successHandler,
   failureHandler, precondition, channel) {
 var call = new Wicket.Ajax.Call(url, successHandler,
 failureHandler,
   channel);
 ...
 return call.submitFormById(formId, submitButton);
}
  
   which calls submitFormById...
submitFormById: function(formId, submitButton) {
 var form = Wicket.$(formId);
 ...
 return this.submitForm(form, submitButton);
}
  
   which calls submitForm passing my nested form (i'm debugging with
  Firebug)
// Submits a form using ajax.
// This method serializes a form and sends it as POST body.
submitForm: function(form, submitButton) {
 var body = function() {
   var s = Wicket.Form.serialize(form);
   if (submitButton != null) {
 s += Wicket.Form.encode(submitButton) + =1;
   }
   return s;
 }
 return this.request.post(body);
}
  
   which ultimately calls Wicket.Form.serialize(form) with my nested
 form,
  not
   with the root form.
  
   Am i right?
  
   German
  
   PS: meanwhile i'm trying to produce a quickstart... but i guess it
 will
  take
   me some time.
   2008/9/10 Matej Knopp [EMAIL PROTECTED]
  
   But that is exactly what should happen. Wicket javascript should
 find
   root form element and serialize that. Can you please check in your
   markup if there are any nested form tags? (shouldn't be).
  
   -Matej
  
   On Wed, Sep 10, 2008 at 8:11 PM, German Morales
   [EMAIL PROTECTED] wrote:
That would be somehow complicated to produce right now.
   
To make my question different... why the javascript side sends
 only
  the
nested form info (wicketSubmitFormById()) and on wicket side the
 root
   form
is the one that gets called?
   
I've already tried and it works ok if i make the nested form do
 the
processing instead of the root form.
   protected void onEvent(AjaxRequestTarget target) {
   getForm().onFormSubmitted();  // getRootForm() removed
   
Another possibility would be that javascript side sends the values
 for
   the
root form, and then it would be ok that the root form does the
   processing.
   
Thanks,
   
German
   
   
2008/9/10 Matej Knopp [EMAIL PROTECTED]
   
I would need a quick start to see where it is going wrong.
   
-Matej
   
On Wed, Sep 10, 2008 at 7:26 PM, German Morales
[EMAIL PROTECTED] wrote

Form values lost in combination of Forms plus ModalWindow

2008-09-09 Thread German Morales
Hi all,

I've a problem with Forms and ModalWindows.

I have this stuff:
-a page with a main Form (the only one that is rendered as an HTML form tag)
-this my only page, since all inside it is changed by replacing panels using
ajax.
-inside some other levels of panels, i have a panel with my content (let me
call it myContentPanel), which has its own (sub) Form (which is rendered as
a div).
-myContentPanel has some controls... TextFields, DropDownChoices,
CheckBoxes.
-myContentPanel has also a link that opens a ModalWindow.
-the ModalWindow has its own Form with components, and an AjaxSubmitLink to
close it.

Now the problem...
1- I enter to myContentPanel and enter some values in the components.
2- I press the link to open the ModalWindow.
3- I work with the ModalWindow, then press an AjaxSubmitLink to close it.
4- When refreshing myContentPanel, the values in some controls is lost:
CheckBoxes, DropDownChoices, but NOT in TextFields.

After some investigation, this is what i've discovered:
-on step 3 (accept and close the ModalWindow), the AjaxSubmitLink calls
(javascript) wicketSubmitFormById passing the ModalWindow's form as
parameter.
-this processes the ModalWindow's form and prepares the values to be sent to
wicket side.
-but when i see the url, it mentions that the form that will be used for the
HTTP request is the page's form (because it's the only real form, i think
this is normal).
-on wicket side, the request processing calls Form#onFormSubmitted, which
calls #inputChanged, which calls a visitor visiting all components... in the
main form!
-this ends up calling FormComponent#inputChanged on the CheckBoxes,
DropDownChoices, TextFields that where in myContentPanel (also for the
controls in the ModalWindow, but that's no surprise).
-given that the javascript only prepared the data for the ModalWindow's
form, the values for the components in myContentPanel is empty.
-looking deeper in #inputChanged, getInputAsArray() gives null for the
components in myContentPanel.
-then, since CheckBox and DropDownChoice answer true to isInputNullable()
(default in FormComponent), the rawInput is set to null, even if i didn't
touch the CheckBoxes/DropDownChoices at all in this call (then losing the
previous value: NO_RAW_INPUT).
-on step 4, when the CheckBox/DropDownChoice wants to get rendered again,
onComponentTag calls FormComponent#getValue, which if
(NO_RAW_INPUT.equals(rawInput)) uses the Model to get the value (what i
would expect), but in my case returns the rawInput (null... ouch).

I have fixed it temporaly by overriding isInputNullable in my
CheckBoxes/DropDownChoice, but i understand that this is not a very good
solution.

Some doubts that remain:
-is there anything wrong with my structure of forms and panels, which is
actually producing these side effects?
-if only the values for ModalWindow form are sent to the server, why the is
onFormSubmitted called on the main page form?
-the javadoc in isInputNullable is not very clear for me... do i break
something else if i override isInputNullable answering false?

Thanks in advance,

German


Re: Form values lost in combination of Forms plus ModalWindow

2008-09-09 Thread German Morales
Hi Matej,

Thanks for the answer.

I have an AjaxSubmitLink both for opening and closing the modal window.
Should that make any trouble?
In both cases i have data to persist, so it must be a .*Submit.* component.

Also, my problem happens when closing the window, not when opening it.
I summarize it again:
-the browser sends an ajax call with the values in the modal window
-but on wicket side the main form of the page is the one that takes charge
-the components on the page then receive the new input, but there's actually
nothing coming from the browser for them
-some components (text components) handle it well, some not (checkbox,
dropdownchoice).
-the misbehaving component get a rawinput of null instead of NO_RAW_INPUT,
which then produces the side effect that the component does not get the
value from the model on rendering.

Please see the doubts section at the end of the original e-mail.

Thanks again,

German

2008/9/9 Matej Knopp [EMAIL PROTECTED]

 The link that shows the modal window must be AjaxButton/SubmitLink.

 -Matej

 On Tue, Sep 9, 2008 at 11:20 PM, German Morales
 [EMAIL PROTECTED] wrote:
  Hi all,
 
  I've a problem with Forms and ModalWindows.
 
  I have this stuff:
  -a page with a main Form (the only one that is rendered as an HTML form
 tag)
  -this my only page, since all inside it is changed by replacing panels
 using
  ajax.
  -inside some other levels of panels, i have a panel with my content (let
 me
  call it myContentPanel), which has its own (sub) Form (which is rendered
 as
  a div).
  -myContentPanel has some controls... TextFields, DropDownChoices,
  CheckBoxes.
  -myContentPanel has also a link that opens a ModalWindow.
  -the ModalWindow has its own Form with components, and an AjaxSubmitLink
 to
  close it.
 
  Now the problem...
  1- I enter to myContentPanel and enter some values in the components.
  2- I press the link to open the ModalWindow.
  3- I work with the ModalWindow, then press an AjaxSubmitLink to close it.
  4- When refreshing myContentPanel, the values in some controls is lost:
  CheckBoxes, DropDownChoices, but NOT in TextFields.
 
  After some investigation, this is what i've discovered:
  -on step 3 (accept and close the ModalWindow), the AjaxSubmitLink calls
  (javascript) wicketSubmitFormById passing the ModalWindow's form as
  parameter.
  -this processes the ModalWindow's form and prepares the values to be sent
 to
  wicket side.
  -but when i see the url, it mentions that the form that will be used for
 the
  HTTP request is the page's form (because it's the only real form, i think
  this is normal).
  -on wicket side, the request processing calls Form#onFormSubmitted, which
  calls #inputChanged, which calls a visitor visiting all components... in
 the
  main form!
  -this ends up calling FormComponent#inputChanged on the CheckBoxes,
  DropDownChoices, TextFields that where in myContentPanel (also for the
  controls in the ModalWindow, but that's no surprise).
  -given that the javascript only prepared the data for the ModalWindow's
  form, the values for the components in myContentPanel is empty.
  -looking deeper in #inputChanged, getInputAsArray() gives null for the
  components in myContentPanel.
  -then, since CheckBox and DropDownChoice answer true to isInputNullable()
  (default in FormComponent), the rawInput is set to null, even if i didn't
  touch the CheckBoxes/DropDownChoices at all in this call (then losing the
  previous value: NO_RAW_INPUT).
  -on step 4, when the CheckBox/DropDownChoice wants to get rendered again,
  onComponentTag calls FormComponent#getValue, which if
  (NO_RAW_INPUT.equals(rawInput)) uses the Model to get the value (what i
  would expect), but in my case returns the rawInput (null... ouch).
 
  I have fixed it temporaly by overriding isInputNullable in my
  CheckBoxes/DropDownChoice, but i understand that this is not a very good
  solution.
 
  Some doubts that remain:
  -is there anything wrong with my structure of forms and panels, which is
  actually producing these side effects?
  -if only the values for ModalWindow form are sent to the server, why the
 is
  onFormSubmitted called on the main page form?
  -the javadoc in isInputNullable is not very clear for me... do i break
  something else if i override isInputNullable answering false?
 
  Thanks in advance,
 
  German
 

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




Problem rendering not visible Form with OutputMarkupPlaceholderTag

2008-09-01 Thread German Morales
Hi all,

We had suffered an strange behavior, which i would like to share for
comments.
We have a Panel (loaded with ajax) with many Forms inside (because each
needs different models).
Some of these Forms are only visible under certain conditions, so we
overwrote isVisible with the condition.
Also, the Panel can be updated, so the Forms have
setOutputMarkupPlaceholderTag(true) to make them visible later.
That triggered a problem in the rendering of the ajax response.

After some investigation, the problem seems to be:
-When a Form is visible, Form#onComponentTag replaces the tag form by
div (because it's nor the Root form of the page), this works ok.
-When a Form is invisible, Form#onComponentTag is never called. Instead,
Component#render builds the response by itself, using
markupStream.getTag().getName(), which answers the tag form.
-Then, the ajax response has a mix of div and form. Apparently, all goes
ok until the first form is found, then the parsing goes somehow crazy and
this first form gets lost from the DOM, and the next forms and divs get
inserted outside (one level in DOM) the main component being replaced by the
ajax call.

We have found no way to fix it in the Form class itself. Component uses
markupStream.getTag() (which answers form). That is, it does not ask the
component for the tag to answer, but instead trusts in the HTML side. And we
can't change our html to say div, because Form also checks (when visible)
that the tag says form (checkComponentTag(tag, form)).

The solution was to put the missbehaving forms inside Panels, which do not
suffer this problem, and then make the panels visible/invisible (also with
OutputMarkupPlaceholderTag).

We have it running now, but we wanted to know if there was some better
solution, or perpahs something should be fixed to prevent future problems,
for example:
-inform somehow if a form is being set as invisible with
setOutputMarkupPlaceholderTag(true)?
-let Component ask itself for the tag to output in case of invisible +
setOutputMarkupPlaceholderTag(true), instead of just putting what the markup
says... then Form could say no, i want a div here.
-other?

Thanks in advance,

German


Re: Problem rendering not visible Form with OutputMarkupPlaceholderTag

2008-09-01 Thread German Morales
Hi again,

Thanks for the answer.

https://issues.apache.org/jira/browse/WICKET-1815
I just copied the e-mail in a jira issue, is this enough?

Bye,

German


2008/9/1 Matej Knopp [EMAIL PROTECTED]

 This looks like a bug/design flaw. Can you please open a jira issue?
 This could be solved by having (yet another) method in component that
 would allow to postprocess the placeholder tag.
 The implementation would  be fairly simple. Or maybe we could call
 onComponentTag and then strip all the attributes. This might be better
 idea as it would be consistent with the behavior when component is
 actually rendered.

 -Matej

 On Mon, Sep 1, 2008 at 10:11 PM, German Morales
 [EMAIL PROTECTED] wrote:
  Hi all,
 
  We had suffered an strange behavior, which i would like to share for
  comments.
  We have a Panel (loaded with ajax) with many Forms inside (because each
  needs different models).
  Some of these Forms are only visible under certain conditions, so we
  overwrote isVisible with the condition.
  Also, the Panel can be updated, so the Forms have
  setOutputMarkupPlaceholderTag(true) to make them visible later.
  That triggered a problem in the rendering of the ajax response.
 
  After some investigation, the problem seems to be:
  -When a Form is visible, Form#onComponentTag replaces the tag form by
  div (because it's nor the Root form of the page), this works ok.
  -When a Form is invisible, Form#onComponentTag is never called. Instead,
  Component#render builds the response by itself, using
  markupStream.getTag().getName(), which answers the tag form.
  -Then, the ajax response has a mix of div and form. Apparently, all
 goes
  ok until the first form is found, then the parsing goes somehow crazy
 and
  this first form gets lost from the DOM, and the next forms and divs get
  inserted outside (one level in DOM) the main component being replaced by
 the
  ajax call.
 
  We have found no way to fix it in the Form class itself. Component uses
  markupStream.getTag() (which answers form). That is, it does not ask
 the
  component for the tag to answer, but instead trusts in the HTML side. And
 we
  can't change our html to say div, because Form also checks (when
 visible)
  that the tag says form (checkComponentTag(tag, form)).
 
  The solution was to put the missbehaving forms inside Panels, which do
 not
  suffer this problem, and then make the panels visible/invisible (also
 with
  OutputMarkupPlaceholderTag).
 
  We have it running now, but we wanted to know if there was some better
  solution, or perpahs something should be fixed to prevent future
 problems,
  for example:
  -inform somehow if a form is being set as invisible with
  setOutputMarkupPlaceholderTag(true)?
  -let Component ask itself for the tag to output in case of invisible +
  setOutputMarkupPlaceholderTag(true), instead of just putting what the
 markup
  says... then Form could say no, i want a div here.
  -other?
 
  Thanks in advance,
 
  German
 

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




Re: Rare Style disabling and Ajax Panel Replacement Question

2008-06-20 Thread German Morales
Hi again,

I have come to the following conclusion so far:
-Use detailed CSS specifications is the way to avoid #id clashing.
-We will also keep some automatic disabling of CSSs that are no longer in
use... we will try not to rely on this mechanism though, and still use what
i said in the line above. The disabling of not used CSS will not hurt
anyway, and perhaps avoid some unexpected clashing, so why not keeping it
too, as a backup mechanism. We could discard it later too... we will see,
the main solution is the full detailed css as said above.

Thanks all for the help,

German

2008/6/18 Nino Saturnino Martinez Vazquez Wael [EMAIL PROTECTED]:


 German Morales wrote:

 Hi,

 I'm here with Francisco, discussing this subject.

 The main difference between the approach is the amount of stuff to write
 in
 CSS: With the detailed naming of styles (.DetailPanel-A fieldPersonName)
 you have to write a lot more in the CSS. That is, for each field in
 DetailPanelA, you have to go with .DetailPanelA #fieldWhatever1,
 .DetailPanelA #fieldWhatever2, .DetailPanelA #fieldWhateverN instead
 of
 the shorter versions #fieldWhatever1, #fieldWhatever2,
 #fieldWhateverN. Therefore, the shorter versions should be, in theory,
 easier to write and maintain.


 Yeah I see the point. But could'nt at least try to hit the fields by
 selectors: .DetailPanelA fieldsettextarea {color:black}.

 But on the otherhand you can have one stylesheet that fits all, that could
 be handy if you ever want todo skinning, by css only(which actually can do
 alot see css zen garden).

 On the other hand, producing this #fieldWhatever1 allows the conflict
 between fieldWhatever1 in DetailPanelA and DetailPanelB, which means that
 we
 must introduce some trick to avoid it.

 Yup popular called clashing.

  Someone here has found this
 disabling of CSSs.

 I think this approach are okay doing simple static pages. But once you
 mixin ajax trouble begin to rise, and what happens if you have two of the
 panels clashing in the same page who should win?

  It is nice because it could be handled in a somehow
 generic way (allowing producers of DetailPanelN to be un-aware of all this
 complication), but also we must consider that it adds some extra
 complexity.


 Yes it does, but on the other hand, it lessen the burden on the css
 designer, so it's a tradoff.

 I'm not completely in favor of one or another approach. The detailed style
 version is in fact our current solution, and it has the benefit of being
 simple. But we are trying also the CSS disabling because it has some
 not-that-bad benefits (CSS simplification, and perhaps the possibility of
 forget about the CSS conflicts altogether).

 That's why we would like to hear opinions, and perhaps even more
 importantly, hear about different approaches, or about hidden traps in our
 current attempts.


 Understandable.. I too are looking forward to hear different opinions:)

  Thanks in advance,

 German

 2008/6/18 Francisco Diaz Trepat - gmail [EMAIL PROTECTED]:



 That was my approach exactly but I lack the arguments to convince them.
 I
 managed to send this mail and see if I'll get better ones :-), or at
 least
 community consensus.

 Maybe if I started a thread I could get some other experiences and
 opinions
 on the matter.

 Thanks Nino.

 f(t)

 On Wed, Jun 18, 2008 at 1:49 PM, Nino Saturnino Martinez Vazquez Wael 
 [EMAIL PROTECTED] wrote:



 Hi Francisco

 I'd much rather go with more detailed naming of your styles, instead of
 doing complex stuff with dom? Like

 .DetailPanel-A-fieldPersonName{
  position:absolute;
  left:50px;
  top: 50px;
 }

 Or maybe the problem are more complex than this..?

 Francisco Diaz Trepat - gmail wrote:



 Hi all, its been a while.

 Finally we started migrating other applications from swing to wicket
 thanks
 to all your help provided last year.

 Having said that, I have some colleagues that are looking to develop a


 way


 to disable style sheets that are loaded as part of panel replacement.

 Here is the Scenario:

 we have a classic web structure: left menu, top header, and center to
 right
 Detail area.

 The detail area is replaced by wicket-ajax functions and each panel
 usually
 has an overriden renderHead with code similar to this one:

 cHtmlHeaderContainer.getHeaderResponse().renderCSSReference(new
 ResourceReference(
   this.getClass(),
   this.getClass().getSimpleName() + .css,
   getLocale(),
   getStyle()));


 Because on more than one detail panel they use a same field but with
 different position (lets say person.name) they are experiencing some
 style
 collision.

 Lets say that DetailPanel-A and DetailPanel-B show a text-field with
 the
 person.name and displays them in different locations. Surely now we


 have


 the
 same style name (by class (.) or by id (#) in some versions).

 So we have two .css files.

 *DetailPanel-A.css* with:

 .fieldPersonName{
  position

Re: Rare Style disabling and Ajax Panel Replacement Question

2008-06-18 Thread German Morales
Hi,

I'm here with Francisco, discussing this subject.

The main difference between the approach is the amount of stuff to write in
CSS: With the detailed naming of styles (.DetailPanel-A fieldPersonName)
you have to write a lot more in the CSS. That is, for each field in
DetailPanelA, you have to go with .DetailPanelA #fieldWhatever1,
.DetailPanelA #fieldWhatever2, .DetailPanelA #fieldWhateverN instead of
the shorter versions #fieldWhatever1, #fieldWhatever2,
#fieldWhateverN. Therefore, the shorter versions should be, in theory,
easier to write and maintain.

On the other hand, producing this #fieldWhatever1 allows the conflict
between fieldWhatever1 in DetailPanelA and DetailPanelB, which means that we
must introduce some trick to avoid it. Someone here has found this
disabling of CSSs. It is nice because it could be handled in a somehow
generic way (allowing producers of DetailPanelN to be un-aware of all this
complication), but also we must consider that it adds some extra complexity.

I'm not completely in favor of one or another approach. The detailed style
version is in fact our current solution, and it has the benefit of being
simple. But we are trying also the CSS disabling because it has some
not-that-bad benefits (CSS simplification, and perhaps the possibility of
forget about the CSS conflicts altogether).

That's why we would like to hear opinions, and perhaps even more
importantly, hear about different approaches, or about hidden traps in our
current attempts.

Thanks in advance,

German

2008/6/18 Francisco Diaz Trepat - gmail [EMAIL PROTECTED]:

 That was my approach exactly but I lack the arguments to convince them. I
 managed to send this mail and see if I'll get better ones :-), or at least
 community consensus.

 Maybe if I started a thread I could get some other experiences and opinions
 on the matter.

 Thanks Nino.

 f(t)

 On Wed, Jun 18, 2008 at 1:49 PM, Nino Saturnino Martinez Vazquez Wael 
 [EMAIL PROTECTED] wrote:

  Hi Francisco
 
  I'd much rather go with more detailed naming of your styles, instead of
  doing complex stuff with dom? Like
 
  .DetailPanel-A-fieldPersonName{
   position:absolute;
   left:50px;
   top: 50px;
  }
 
  Or maybe the problem are more complex than this..?
 
  Francisco Diaz Trepat - gmail wrote:
 
  Hi all, its been a while.
 
  Finally we started migrating other applications from swing to wicket
  thanks
  to all your help provided last year.
 
  Having said that, I have some colleagues that are looking to develop a
 way
  to disable style sheets that are loaded as part of panel replacement.
 
  Here is the Scenario:
 
  we have a classic web structure: left menu, top header, and center to
  right
  Detail area.
 
  The detail area is replaced by wicket-ajax functions and each panel
  usually
  has an overriden renderHead with code similar to this one:
 
  cHtmlHeaderContainer.getHeaderResponse().renderCSSReference(new
  ResourceReference(
 this.getClass(),
 this.getClass().getSimpleName() + .css,
 getLocale(),
 getStyle()));
 
 
  Because on more than one detail panel they use a same field but with
  different position (lets say person.name) they are experiencing some
  style
  collision.
 
  Lets say that DetailPanel-A and DetailPanel-B show a text-field with the
  person.name and displays them in different locations. Surely now we
 have
  the
  same style name (by class (.) or by id (#) in some versions).
 
  So we have two .css files.
 
  *DetailPanel-A.css* with:
 
  .fieldPersonName{
position:absolute;
left:50px;
top: 50px;
  }
 
  *DetailPanel-B.css* with:
 
  .fieldPersonName{
background-color:   yellow;
  }
 
  Now we navigate from DetailPanel-A to DetailPanel-B or viceversa. And
  ofcourse the problem is that on the DetailPanel-B my field gets moved
 if
  I
  don't specify otherwise. And some times although we specify it, it will
  depend on order and other matters as well. This are the rules of the
 game
  and web development has been fine with them.
 
  But my colleages are proposing a disabling of previously loaded styles,
  living DOM with disabled style objects.
 
  I haven't heard of that kind of practice. And IMHO instead of building a
  complex javascript function to disable the style object (link
  rel=stylesheet type=text/css charset=utf-8 media=all
  href=someWicketResourceUrl) on the pages DOM object, we could share
  this
  with wicket community and find out if we are on the right path. I don't
  feel
  we are in it.
 
  Could some please comment on this, or ask anything you need to comment
 on
  this desing issue.
 
  Thanks,
  f(t)
 
 
 
 
  --
  -Wicket for love
 
  Nino Martinez Wael
  Java Specialist @ Jayway DK
  http://www.jayway.dk
  +45 2936 7684
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, 

Re: Rare Style disabling and Ajax Panel Replacement Question

2008-06-18 Thread German Morales
Igor,

Yes, in such case the only solution is the full detailed style info.
In our case, however, we talk about panels that always replace each other.
Or at least that is the common case. Perhaps finding cases that does not
follow this rule helps to solve this dilemma.

Thanks for the new point of view,

German

2008/6/18 Igor Vaynberg [EMAIL PROTECTED]:

 what happens if you ever need to use both panels on the page
 simultaneously. personally i would stick with the .panela selector
 stylesheets

 -igor

 On Wed, Jun 18, 2008 at 11:28 AM, German Morales
 [EMAIL PROTECTED] wrote:
  Hi,
 
  I'm here with Francisco, discussing this subject.
 
  The main difference between the approach is the amount of stuff to write
 in
  CSS: With the detailed naming of styles (.DetailPanel-A
 fieldPersonName)
  you have to write a lot more in the CSS. That is, for each field in
  DetailPanelA, you have to go with .DetailPanelA #fieldWhatever1,
  .DetailPanelA #fieldWhatever2, .DetailPanelA #fieldWhateverN instead
 of
  the shorter versions #fieldWhatever1, #fieldWhatever2,
  #fieldWhateverN. Therefore, the shorter versions should be, in theory,
  easier to write and maintain.
 
  On the other hand, producing this #fieldWhatever1 allows the conflict
  between fieldWhatever1 in DetailPanelA and DetailPanelB, which means that
 we
  must introduce some trick to avoid it. Someone here has found this
  disabling of CSSs. It is nice because it could be handled in a somehow
  generic way (allowing producers of DetailPanelN to be un-aware of all
 this
  complication), but also we must consider that it adds some extra
 complexity.
 
  I'm not completely in favor of one or another approach. The detailed
 style
  version is in fact our current solution, and it has the benefit of being
  simple. But we are trying also the CSS disabling because it has some
  not-that-bad benefits (CSS simplification, and perhaps the possibility of
  forget about the CSS conflicts altogether).
 
  That's why we would like to hear opinions, and perhaps even more
  importantly, hear about different approaches, or about hidden traps in
 our
  current attempts.
 
  Thanks in advance,
 
  German
 
  2008/6/18 Francisco Diaz Trepat - gmail [EMAIL PROTECTED]
 :
 
  That was my approach exactly but I lack the arguments to convince
 them. I
  managed to send this mail and see if I'll get better ones :-), or at
 least
  community consensus.
 
  Maybe if I started a thread I could get some other experiences and
 opinions
  on the matter.
 
  Thanks Nino.
 
  f(t)
 
  On Wed, Jun 18, 2008 at 1:49 PM, Nino Saturnino Martinez Vazquez Wael 
  [EMAIL PROTECTED] wrote:
 
   Hi Francisco
  
   I'd much rather go with more detailed naming of your styles, instead
 of
   doing complex stuff with dom? Like
  
   .DetailPanel-A-fieldPersonName{
position:absolute;
left:50px;
top: 50px;
   }
  
   Or maybe the problem are more complex than this..?
  
   Francisco Diaz Trepat - gmail wrote:
  
   Hi all, its been a while.
  
   Finally we started migrating other applications from swing to wicket
   thanks
   to all your help provided last year.
  
   Having said that, I have some colleagues that are looking to develop
 a
  way
   to disable style sheets that are loaded as part of panel replacement.
  
   Here is the Scenario:
  
   we have a classic web structure: left menu, top header, and center to
   right
   Detail area.
  
   The detail area is replaced by wicket-ajax functions and each panel
   usually
   has an overriden renderHead with code similar to this one:
  
   cHtmlHeaderContainer.getHeaderResponse().renderCSSReference(new
   ResourceReference(
  this.getClass(),
  this.getClass().getSimpleName() + .css,
  getLocale(),
  getStyle()));
  
  
   Because on more than one detail panel they use a same field but
 with
   different position (lets say person.name) they are experiencing some
   style
   collision.
  
   Lets say that DetailPanel-A and DetailPanel-B show a text-field with
 the
   person.name and displays them in different locations. Surely now we
  have
   the
   same style name (by class (.) or by id (#) in some versions).
  
   So we have two .css files.
  
   *DetailPanel-A.css* with:
  
   .fieldPersonName{
 position:absolute;
 left:50px;
 top: 50px;
   }
  
   *DetailPanel-B.css* with:
  
   .fieldPersonName{
 background-color:   yellow;
   }
  
   Now we navigate from DetailPanel-A to DetailPanel-B or viceversa. And
   ofcourse the problem is that on the DetailPanel-B my field gets
 moved
  if
   I
   don't specify otherwise. And some times although we specify it, it
 will
   depend on order and other matters as well. This are the rules of the
  game
   and web development has been fine with them.
  
   But my colleages are proposing a disabling of previously loaded
 styles,
   living DOM with disabled style

Re: Link to dynamic pdf (jasperreports)

2007-12-06 Thread German Morales
Hi,

Have you seen this other thread?
http://www.nabble.com/wicket-File-downlaod-tf4874269.html#a13946961

There i've made some suggestions for dynamic generated pdf, with working
code.

Again, i don't know anything of jasper reports, but the person asked that
time liked it.

Also there is in the code the needed call to make it work with the
download dialog.

Bye,

German


It seems that Newgro wrote:

 Is this really unsolvable? Please can someone give me a hint?

 Thanks
 Per
 --
 View this message in context:
 http://www.nabble.com/Link-to-dynamic-pdf-%28jasperreports%29-tf4936362.html#a14191604
 Sent from the Wicket - User mailing list archive at Nabble.com.



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: wicket File downlaod

2007-11-26 Thread German Morales
Hi,

I have never used jasper reports, but a quick search shows me that you can
also generate the file as a byte[] in memory:

http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/JasperExportManager.html#exportReportToPdf(net.sf.jasperreports.engine.JasperPrint)

Class JasperExportManager:
public static byte[] exportReportToPdf(JasperPrint jasperPrint) throws
JRException

In such case you could avoid all the trouble with files by using a
DynamicWebResource instead of the WebResource described by Florian.

Here a quick example:

   public class MyDynamicWebResource extends DynamicWebResource {
  protected ResourceState getResourceState() {
 return new ResourceState() {
public String getContentType() {
   return application/pdf;
}

public byte[] getData() {
   return generatePDFDataUsingJasperOrWhatever();
}
 };
  }

  // this is optional i think
  protected void setHeaders(WebResponse cResponse) {
 super.setHeaders(cResponse);

 cResponse.setAttachmentHeader(test.pdf);
  }
   }

For me this is the most convenient thing to do if you don't need to store
the files for later usage.

Bye,

German


It seems that Florian Sperber wrote:
 Sometime ago this was answered on the list but i cannot find it right
 now :-)

 Maybe the following snippets will help you (it's wicket 1.2.6):

 WebResource export = new WebResource() {
   private static final long serialVersionUID = 1L;

   @Override
   public IResourceStream getResourceStream() {
   try {
   return new FileService(f).getResourceStream();
   } catch (IOException e) {
   e.printStackTrace();
   }
   return null;
   }
   @Override
   protected void setHeaders(WebResponse response) {
   super.setHeaders(response);
   response.
   setAttachmentHeader(attachment.getOriginalFilename());
   }
 };
 export.setCacheable(false);

 ResourceLink dlLink = new ResourceLink(attachmentLink, export);

 ...

 public class FileService {

   private File file;
   private String outputName;
   private String contentType = ;

   public FileService(File file) {
   this.file = file;
   this.outputName = this.file.getName();
   }

   /**
* sets the output name and returns itself
* @param outputName
* @return
*/
   public FileService setOutputName(String outputName) {
   this.outputName = outputName;
   return FileService.this;
   }

   /**
* sets the content type and returns itself
* @param contentType
* @return
*/
   public FileService setContentType(String contentType) {
   this.contentType = contentType;
   return FileService.this;
   }


   public IResourceStream getResourceStream() throws IOException {

   FileInputStream fi = new FileInputStream(this.file);

   return new IResourceStreamImpl(fi, this.contentType,
 this.file.length());
   }

   /**
* wrapper which creates the necessary [EMAIL PROTECTED]
 ResourceStreamRequestTarget}
* @return
* @throws IOException
*/
   public ResourceStreamRequestTarget getResourceStreamRequestTarget()
 throws IOException {
   return new 
 ResourceStreamRequestTarget(this.getResourceStream()) {
   public String getFileName() {
   return (outputName);
   }
   };
   }

 }

 ...
 public class IResourceStreamImpl implements IResourceStream {
   private static final long serialVersionUID = 1L;

   private Locale locale = null;
   private String contentType = null;
   private InputStream inputStream = null;
   private long size;

   /**
* @param fileInputStream
* @param contentType
* @param file
*/
   public IResourceStreamImpl(InputStream inputStream,
   String contentType, long size) {
   this.inputStream = inputStream;
   this.size = size;
   this.contentType = contentType;
   }

   public void close() throws IOException {
   this.inputStream.close();
   }

   public InputStream getInputStream() throws
 ResourceStreamNotFoundException {
   return this.inputStream;
   }

   public String getContentType() {
   return (this.contentType);
   }

   public Locale getLocale() {
   return (this.locale);
   }

   public long length() {
   return this.size;
   }

   public void setLocale(Locale locale) {
   this.locale = locale;
   }

   public Time lastModifiedTime() {
   return 

Re: ResourceReference with locale and style, for CSSs

2007-11-10 Thread German Morales
Ok, please give me some time, i will ask someone (who is reading) with
Netbeans 6 already installed to help me produce a quickstart.

Anyway, i insist that now is all working for me, just that it is strange
that it generates the HTML referencing the CSS with full locale and style,
and then when the browser ask for the file, it seems that in that moment
the look up is done and the correct available file is found. Perhaps
that's the way it is supposed to work?

German

It seems that Johan Compagner wrote:
 can you make a test case for this and attach it to an issue in your jira?

 I did fix something in RC1 but i don't know if your case is fixed

 The problem is that when you get or generate an url from a
 ResourceReference
 first bind() should be called. If that is then a PackageResource then the
 ResourceReference
 should get the locale of the PackageResource but i see that there could be
 some issues with that.

 But what doesn't happen is that the headerresponse doesn't call bind() for
 us when you add a resource reference
 that should also be fixed

 johan

 On Nov 9, 2007 5:54 PM, German Morales [EMAIL PROTECTED]
 wrote:

 1.3.0 beta 4

 It seems that Johan Compagner wrote:
  I think i asked this before, but what version of wicket??
 
  Normally (in the current wicket 1.3 buids) a ResourceReference to a
  PackageResource will fallback to the real locale the PackageResource
 is
  loaded
  from after the ResourceReference is binded.
 
  johan
 
  On Nov 9, 2007 3:34 PM, German Morales [EMAIL PROTECTED]
  wrote:
 
  Yes, at least that's what i see when i ask Firefox to show me the
 source
  of the page.
 
  It seems that Johan Compagner wrote:
   But even with bind() it still shows you the locale in the url?
  
   On Nov 9, 2007 3:22 PM, German Morales
 [EMAIL PROTECTED]
   wrote:
  
   Hi again,
  
   With your solution, the generated HTML now looks this way:
  
   link rel=stylesheet type=text/css
   href=resources/path.to.mypage.MyPage/style_mystyle_mylocale.css
 /
  
   i don't have style_mystyle_mylocale.css, but only
 style_mystyle.css
  
   But it works!
  
   So it seems that wicket later (when the browser asks for the css)
  makes
   the corresponding look up.
  
   Thanks a lot!
  
   German
  
   PS: just for the record (if someone reads this later), there was a
  easy
   typo in the code below. It should be Application.get() and not
   Application.bind().
  
   It seems that Johan Compagner wrote:
no as i said before
you have to create the resourcereference with the locale and the
   style.
Those are not automatically picked up from the session. If you
  don't
   give
them in the constructor
then both are just null
   
What you could do is this:
   
ResourceReference reference = new
 ResourceReference(MyPage.class,
style.css,
locale,style);
reference.bind(Application.bind());
cResponse.getHeaderResponse().renderCSSReference(reference);
johan
   
   
   
On Nov 9, 2007 1:55 PM, German Morales
  [EMAIL PROTECTED]
wrote:
   
version 1.3.0-beta4.
   
I insist that the problem must be something different, perhaps
 in
  the
way
i pretend it to work. I know about the ResourceStreamLocator,
 and
  as
   i
tell it works perfectly for the HTML. The difference is that
 from
  my
class
the framework looks automatically for the corresponding HTML,
 but
  how
should it work for the CSS?
   
Should i declare it in the code?
   
  // on renderHead
  cResponse.getHeaderResponse().renderCSSReference(new
ResourceReference(MyPage.class, style.css));
   
or how?
   
What i'm doing is very simple... i'm forcing (for testing) a
 call
  to
Session.setStyle(whatever), then i have MyPage.html and
MyPage_whatever.html (which works fine) and then style.css and
style_whatever.css (which i expect to be used thanks to the
 code
   above).
   
But when i see the generated html, it comes with the content of
MyPage_whatever.html, but the header is generated this way:
   
link rel=stylesheet type=text/css
href=resources/path.to.mypage.MyPage/style.css /
   
that is, not pointint to style_whatever.css as i expect.
   
Thanks for the support,
   
German
   
   
It seems that Johan Compagner wrote:
 it should fallback just fine..
 what version of wicket are you using?

 Because in the ResourceStreamLocator we do now this:

 public IResourceStream locate(final Class clazz, String path,
  final
String
 style,
final Locale locale, final String extension)
  {
   // Try the various combinations of style, locale and
 extension
  to
find
   // the resource.
   ResourceNameIterator iter = new ResourceNameIterator(path,
  style,
 locale,
 extension);
   while (iter.hasNext())
   {
String newPath = (String)iter.next();
IResourceStream stream = locate(clazz, newPath);
if (stream != null

Re: ResourceReference with locale and style, for CSSs

2007-11-10 Thread German Morales
So perhaps there's nothing wrong after all?

It seems that Igor Vaynberg wrote:
 when wicket generates the links it appends your browser's locale to them

 so the link to foo.css will look like foo_en_us.css for example.

 then when the url is requested wicket does the resolution with fallback:

 first try foo_en_us.css
 then try foo_en.css
 then try foo.css

 so it all still works...

 im not sure if there is a way for us to generate a url only with
 foo.css in it, because then wicket has to perform the same kind of
 resolution at url generation time... johan?

 -igor


 On Nov 10, 2007 11:48 AM, German Morales [EMAIL PROTECTED]
 wrote:
 Ok, please give me some time, i will ask someone (who is reading) with
 Netbeans 6 already installed to help me produce a quickstart.

 Anyway, i insist that now is all working for me, just that it is strange
 that it generates the HTML referencing the CSS with full locale and
 style,
 and then when the browser ask for the file, it seems that in that moment
 the look up is done and the correct available file is found. Perhaps
 that's the way it is supposed to work?


 German

 It seems that Johan Compagner wrote:
  can you make a test case for this and attach it to an issue in your
 jira?
 
  I did fix something in RC1 but i don't know if your case is fixed
 
  The problem is that when you get or generate an url from a
  ResourceReference
  first bind() should be called. If that is then a PackageResource then
 the
  ResourceReference
  should get the locale of the PackageResource but i see that there
 could be
  some issues with that.
 
  But what doesn't happen is that the headerresponse doesn't call bind()
 for
  us when you add a resource reference
  that should also be fixed
 
  johan
 
  On Nov 9, 2007 5:54 PM, German Morales [EMAIL PROTECTED]
  wrote:
 
  1.3.0 beta 4
 
  It seems that Johan Compagner wrote:
   I think i asked this before, but what version of wicket??
  
   Normally (in the current wicket 1.3 buids) a ResourceReference to a
   PackageResource will fallback to the real locale the
 PackageResource
  is
   loaded
   from after the ResourceReference is binded.
  
   johan
  
   On Nov 9, 2007 3:34 PM, German Morales
 [EMAIL PROTECTED]
   wrote:
  
   Yes, at least that's what i see when i ask Firefox to show me the
  source
   of the page.
  
   It seems that Johan Compagner wrote:
But even with bind() it still shows you the locale in the url?
   
On Nov 9, 2007 3:22 PM, German Morales
  [EMAIL PROTECTED]
wrote:
   
Hi again,
   
With your solution, the generated HTML now looks this way:
   
link rel=stylesheet type=text/css
href=resources/path.to.mypage.MyPage/style_mystyle_mylocale.css
  /
   
i don't have style_mystyle_mylocale.css, but only
  style_mystyle.css
   
But it works!
   
So it seems that wicket later (when the browser asks for the
 css)
   makes
the corresponding look up.
   
Thanks a lot!
   
German
   
PS: just for the record (if someone reads this later), there
 was a
   easy
typo in the code below. It should be Application.get() and not
Application.bind().
   
It seems that Johan Compagner wrote:
 no as i said before
 you have to create the resourcereference with the locale and
 the
style.
 Those are not automatically picked up from the session. If
 you
   don't
give
 them in the constructor
 then both are just null

 What you could do is this:

 ResourceReference reference = new
  ResourceReference(MyPage.class,
 style.css,
 locale,style);
 reference.bind(Application.bind());
 cResponse.getHeaderResponse().renderCSSReference(reference);
 johan



 On Nov 9, 2007 1:55 PM, German Morales
   [EMAIL PROTECTED]
 wrote:

 version 1.3.0-beta4.

 I insist that the problem must be something different,
 perhaps
  in
   the
 way
 i pretend it to work. I know about the
 ResourceStreamLocator,
  and
   as
i
 tell it works perfectly for the HTML. The difference is that
  from
   my
 class
 the framework looks automatically for the corresponding
 HTML,
  but
   how
 should it work for the CSS?

 Should i declare it in the code?

   // on renderHead
   cResponse.getHeaderResponse().renderCSSReference(new
 ResourceReference(MyPage.class, style.css));

 or how?

 What i'm doing is very simple... i'm forcing (for testing) a
  call
   to
 Session.setStyle(whatever), then i have MyPage.html and
 MyPage_whatever.html (which works fine) and then style.css
 and
 style_whatever.css (which i expect to be used thanks to the
  code
above).

 But when i see the generated html, it comes with the content
 of
 MyPage_whatever.html, but the header is generated this way:

 link rel=stylesheet type=text/css
 href=resources/path.to.mypage.MyPage/style.css /

 that is, not pointint

Re: ResourceReference with locale and style, for CSSs

2007-11-09 Thread German Morales
Hi,

I was thinking (as a last hope) that if this works for the HTMLs, i could
provide different HTMLs that point internally to different CSSs, and it
should work. But that would be duplicating the HTML just to have the CSS
changed, and then it's not a good idea.

Perhaps someone can tell me an official way to have localized and styled
CSSs, the wicket way?

Thanks again,

German

It seems that German Morales wrote:
 Hi,

 I use it inside a page.

 I've tried...

// inside the page constructor
add(HeaderContributor.forCss(new ResourceReference(MyPage.class,
 style.css)));

 and

// inside renderHead
cResponse.getHeaderResponse().renderCSSReference(new
 ResourceReference(MyPage.class, style.css));


 And I don't want to set the style and locale explicitely. What i want is
 to deliver the application to a customer, and, if he wants, he adds the
 customized page for a locale or style by itself (he could set the style
 with a parameter or whatever). And as far as i understand the wicket
 approach, that's how it should work automatically. In fact it works
 perfecly when i do it for the html of the same page. The difference is
 that the html is handled in other way (the framework does it) and when i
 try to do it for the CSS of the page i do it (and it doesn't work). So
 there must be something i'm not doing properly.

 Or, how should be the way to provide styled CSSs, there is another
 aproach?

 thanks and bye,

 German

 It seems that Eelco Hillenius wrote:
 The problem is that the file is there... just that it doesn't seem to
 be
 looking for it.

 If i force the full constructor:

 new ResourceReference(MyPage.class, style.css, getLocale(),
 getStyle())

 all works, so the file is correcly found and the name is correct.

 The problem is when i don't set the locale and style explicitely (as it
 is
 supposed to be done):

 new ResourceReference(MyPage.class, style.css)

 then it doesn't find the file. Actually i think it doesn't even try to
 find it, since as i mention i put a breakpoint in
 ResourceReference#setStyle() and nobody is calling it. So later
 internal
 code to load the resource uses style and locale with null values.

 How do you use the resource reference? I think the class was designed
 in such a way that the components that use it (Image for instance) are
 responsible for setting the appropriate locale/ style 'just in time',
 so that switching locales etc works.

 Eelco

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]





 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: ResourceReference with locale and style, for CSSs

2007-11-09 Thread German Morales
Hi,

Well, i'm not sure to want to be creating the ResourceReferences on my
own. Is there another way to have the same i have for HTML (automatic look
up by the framework for localized and styled versions) but for CSSs?

German

It seems that Johan Compagner wrote:
 if you are creating your own ResourceReferences then you have to give the
 style and locale to them
 We could enhance the constructors that it does Session.get().getLocale()
 and
 Session.get().getStyle()
 if you dont give them..

 johan



 On Nov 9, 2007 10:27 AM, German Morales [EMAIL PROTECTED]
 wrote:

 Hi,

 I was thinking (as a last hope) that if this works for the HTMLs, i
 could
 provide different HTMLs that point internally to different CSSs, and it
 should work. But that would be duplicating the HTML just to have the CSS
 changed, and then it's not a good idea.

 Perhaps someone can tell me an official way to have localized and styled
 CSSs, the wicket way?

 Thanks again,

 German

 It seems that German Morales wrote:
  Hi,
 
  I use it inside a page.
 
  I've tried...
 
 // inside the page constructor
 add(HeaderContributor.forCss(new ResourceReference(MyPage.class,
  style.css)));
 
  and
 
 // inside renderHead
 cResponse.getHeaderResponse().renderCSSReference(new
  ResourceReference(MyPage.class, style.css));
 
 
  And I don't want to set the style and locale explicitely. What i want
 is
  to deliver the application to a customer, and, if he wants, he adds
 the
  customized page for a locale or style by itself (he could set the
 style
  with a parameter or whatever). And as far as i understand the wicket
  approach, that's how it should work automatically. In fact it works
  perfecly when i do it for the html of the same page. The difference is
  that the html is handled in other way (the framework does it) and when
 i
  try to do it for the CSS of the page i do it (and it doesn't work). So
  there must be something i'm not doing properly.
 
  Or, how should be the way to provide styled CSSs, there is another
  aproach?
 
  thanks and bye,
 
  German
 
  It seems that Eelco Hillenius wrote:
  The problem is that the file is there... just that it doesn't seem
 to
  be
  looking for it.
 
  If i force the full constructor:
 
  new ResourceReference(MyPage.class, style.css, getLocale(),
  getStyle())
 
  all works, so the file is correcly found and the name is correct.
 
  The problem is when i don't set the locale and style explicitely (as
 it
  is
  supposed to be done):
 
  new ResourceReference(MyPage.class, style.css)
 
  then it doesn't find the file. Actually i think it doesn't even try
 to
  find it, since as i mention i put a breakpoint in
  ResourceReference#setStyle() and nobody is calling it. So later
  internal
  code to load the resource uses style and locale with null values.
 
  How do you use the resource reference? I think the class was designed
  in such a way that the components that use it (Image for instance)
 are
  responsible for setting the appropriate locale/ style 'just in time',
  so that switching locales etc works.
 
  Eelco
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 



 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]






-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: ResourceReference with locale and style, for CSSs

2007-11-09 Thread German Morales
version 1.3.0-beta4.

I insist that the problem must be something different, perhaps in the way
i pretend it to work. I know about the ResourceStreamLocator, and as i
tell it works perfectly for the HTML. The difference is that from my class
the framework looks automatically for the corresponding HTML, but how
should it work for the CSS?

Should i declare it in the code?

   // on renderHead
   cResponse.getHeaderResponse().renderCSSReference(new
ResourceReference(MyPage.class, style.css));

or how?

What i'm doing is very simple... i'm forcing (for testing) a call to
Session.setStyle(whatever), then i have MyPage.html and
MyPage_whatever.html (which works fine) and then style.css and
style_whatever.css (which i expect to be used thanks to the code above).

But when i see the generated html, it comes with the content of
MyPage_whatever.html, but the header is generated this way:

link rel=stylesheet type=text/css
href=resources/path.to.mypage.MyPage/style.css /

that is, not pointint to style_whatever.css as i expect.

Thanks for the support,

German


It seems that Johan Compagner wrote:
 it should fallback just fine..
 what version of wicket are you using?

 Because in the ResourceStreamLocator we do now this:

 public IResourceStream locate(final Class clazz, String path, final String
 style,
final Locale locale, final String extension)
  {
   // Try the various combinations of style, locale and extension to find
   // the resource.
   ResourceNameIterator iter = new ResourceNameIterator(path, style,
 locale,
 extension);
   while (iter.hasNext())
   {
String newPath = (String)iter.next();
IResourceStream stream = locate(clazz, newPath);
if (stream != null)
{
 stream.setLocale(iter.getLocale());
 return stream;
}
   }
   return null;
  }

 johan



 On Nov 9, 2007 1:11 PM, German Morales [EMAIL PROTECTED]
 wrote:

 Hi again,

 Also, the problem is not giving the parameters to the
 ResourceReferences,
 if i call the full constructor then the ResourceReference works, but the
 problem is that it does not make a look up to see what's available, it
 just goes for the full thing. So, if i call the constructor with the
 session locale and style, what it does is search for the file
 style_mystyle_mylocale.css. This is not my intention, what i want it
 that
 that the framework searches for the style_mystyle_mylocale.css, then if
 not found fall back to style_mystyle.css, style_mylocale.css, style.css
 and so on (i'm not sure of the exact order of look up). So, modifying
 the
 constructor or passing the full parameters is not the solution, i think.


 Regards,

 German

 It seems that Johan Compagner wrote:
   if you are creating your own ResourceReferences then you have to give
 the
  style and locale to them
  We could enhance the constructors that it does
 Session.get().getLocale()
  and
  Session.get().getStyle()
  if you dont give them..
 
  johan
 
 
 
  On Nov 9, 2007 10:27 AM, German Morales [EMAIL PROTECTED]
  wrote:
 
  Hi,
 
  I was thinking (as a last hope) that if this works for the HTMLs, i
  could
  provide different HTMLs that point internally to different CSSs, and
 it
  should work. But that would be duplicating the HTML just to have the
 CSS
  changed, and then it's not a good idea.
 
  Perhaps someone can tell me an official way to have localized and
 styled
  CSSs, the wicket way?
 
  Thanks again,
 
  German
 
  It seems that German Morales wrote:
   Hi,
  
   I use it inside a page.
  
   I've tried...
  
  // inside the page constructor
  add(HeaderContributor.forCss(new ResourceReference(MyPage.class,
   style.css)));
  
   and
  
  // inside renderHead
  cResponse.getHeaderResponse().renderCSSReference(new
   ResourceReference(MyPage.class, style.css));
  
  
   And I don't want to set the style and locale explicitely. What i
 want
  is
   to deliver the application to a customer, and, if he wants, he adds
  the
   customized page for a locale or style by itself (he could set the
  style
   with a parameter or whatever). And as far as i understand the
 wicket
   approach, that's how it should work automatically. In fact it works
   perfecly when i do it for the html of the same page. The difference
 is
   that the html is handled in other way (the framework does it) and
 when
  i
   try to do it for the CSS of the page i do it (and it doesn't work).
 So
   there must be something i'm not doing properly.
  
   Or, how should be the way to provide styled CSSs, there is another
   aproach?
  
   thanks and bye,
  
   German
  
   It seems that Eelco Hillenius wrote:
   The problem is that the file is there... just that it doesn't
 seem
  to
   be
   looking for it.
  
   If i force the full constructor:
  
   new ResourceReference(MyPage.class, style.css, getLocale(),
   getStyle())
  
   all works, so the file is correcly found and the name is correct.
  
   The problem is when i don't set the locale and style explicitely

Re: ResourceReference with locale and style, for CSSs

2007-11-09 Thread German Morales
Hi again,

With your solution, the generated HTML now looks this way:

link rel=stylesheet type=text/css
href=resources/path.to.mypage.MyPage/style_mystyle_mylocale.css /

i don't have style_mystyle_mylocale.css, but only style_mystyle.css

But it works!

So it seems that wicket later (when the browser asks for the css) makes
the corresponding look up.

Thanks a lot!

German

PS: just for the record (if someone reads this later), there was a easy
typo in the code below. It should be Application.get() and not
Application.bind().

It seems that Johan Compagner wrote:
 no as i said before
 you have to create the resourcereference with the locale and the style.
 Those are not automatically picked up from the session. If you don't give
 them in the constructor
 then both are just null

 What you could do is this:

 ResourceReference reference = new ResourceReference(MyPage.class,
 style.css,
 locale,style);
 reference.bind(Application.bind());
 cResponse.getHeaderResponse().renderCSSReference(reference);
 johan



 On Nov 9, 2007 1:55 PM, German Morales [EMAIL PROTECTED]
 wrote:

 version 1.3.0-beta4.

 I insist that the problem must be something different, perhaps in the
 way
 i pretend it to work. I know about the ResourceStreamLocator, and as i
 tell it works perfectly for the HTML. The difference is that from my
 class
 the framework looks automatically for the corresponding HTML, but how
 should it work for the CSS?

 Should i declare it in the code?

   // on renderHead
   cResponse.getHeaderResponse().renderCSSReference(new
 ResourceReference(MyPage.class, style.css));

 or how?

 What i'm doing is very simple... i'm forcing (for testing) a call to
 Session.setStyle(whatever), then i have MyPage.html and
 MyPage_whatever.html (which works fine) and then style.css and
 style_whatever.css (which i expect to be used thanks to the code above).

 But when i see the generated html, it comes with the content of
 MyPage_whatever.html, but the header is generated this way:

 link rel=stylesheet type=text/css
 href=resources/path.to.mypage.MyPage/style.css /

 that is, not pointint to style_whatever.css as i expect.

 Thanks for the support,

 German


 It seems that Johan Compagner wrote:
  it should fallback just fine..
  what version of wicket are you using?
 
  Because in the ResourceStreamLocator we do now this:
 
  public IResourceStream locate(final Class clazz, String path, final
 String
  style,
 final Locale locale, final String extension)
   {
// Try the various combinations of style, locale and extension to
 find
// the resource.
ResourceNameIterator iter = new ResourceNameIterator(path, style,
  locale,
  extension);
while (iter.hasNext())
{
 String newPath = (String)iter.next();
 IResourceStream stream = locate(clazz, newPath);
 if (stream != null)
 {
  stream.setLocale(iter.getLocale());
  return stream;
 }
}
return null;
   }
 
  johan
 
 
 
  On Nov 9, 2007 1:11 PM, German Morales [EMAIL PROTECTED]
  wrote:
 
  Hi again,
 
  Also, the problem is not giving the parameters to the
  ResourceReferences,
  if i call the full constructor then the ResourceReference works, but
 the
  problem is that it does not make a look up to see what's available,
 it
  just goes for the full thing. So, if i call the constructor with the
  session locale and style, what it does is search for the file
  style_mystyle_mylocale.css. This is not my intention, what i want it
  that
  that the framework searches for the style_mystyle_mylocale.css, then
 if
  not found fall back to style_mystyle.css, style_mylocale.css,
 style.css
  and so on (i'm not sure of the exact order of look up). So, modifying
  the
  constructor or passing the full parameters is not the solution, i
 think.
 
 
  Regards,
 
  German
 
  It seems that Johan Compagner wrote:
if you are creating your own ResourceReferences then you have to
 give
  the
   style and locale to them
   We could enhance the constructors that it does
  Session.get().getLocale()
   and
   Session.get().getStyle()
   if you dont give them..
  
   johan
  
  
  
   On Nov 9, 2007 10:27 AM, German Morales
 [EMAIL PROTECTED]
   wrote:
  
   Hi,
  
   I was thinking (as a last hope) that if this works for the HTMLs,
 i
   could
   provide different HTMLs that point internally to different CSSs,
 and
  it
   should work. But that would be duplicating the HTML just to have
 the
  CSS
   changed, and then it's not a good idea.
  
   Perhaps someone can tell me an official way to have localized and
  styled
   CSSs, the wicket way?
  
   Thanks again,
  
   German
  
   It seems that German Morales wrote:
Hi,
   
I use it inside a page.
   
I've tried...
   
   // inside the page constructor
   add(HeaderContributor.forCss(new
 ResourceReference(MyPage.class
 ,
style.css)));
   
and
   
   // inside renderHead
   cResponse.getHeaderResponse().renderCSSReference(new
ResourceReference

Re: ResourceReference with locale and style, for CSSs

2007-11-09 Thread German Morales
Furthermore, now that i understand more about this, i tried again my
original version:

cResponse.getHeaderResponse().renderCSSReference(new
ResourceReference(MyPage.class, style.css, getLocale(), getStyle()));

and it also works as expected.

Perhaps i was not expecting it to work because the generated HTML
referenced a file i didn't have, or who knows why.

Thanks again.

German


It seems that German Morales wrote:
 Hi again,

 With your solution, the generated HTML now looks this way:

 link rel=stylesheet type=text/css
 href=resources/path.to.mypage.MyPage/style_mystyle_mylocale.css /

 i don't have style_mystyle_mylocale.css, but only style_mystyle.css

 But it works!

 So it seems that wicket later (when the browser asks for the css) makes
 the corresponding look up.

 Thanks a lot!

 German

 PS: just for the record (if someone reads this later), there was a easy
 typo in the code below. It should be Application.get() and not
 Application.bind().

 It seems that Johan Compagner wrote:
 no as i said before
 you have to create the resourcereference with the locale and the style.
 Those are not automatically picked up from the session. If you don't
 give
 them in the constructor
 then both are just null

 What you could do is this:

 ResourceReference reference = new ResourceReference(MyPage.class,
 style.css,
 locale,style);
 reference.bind(Application.bind());
 cResponse.getHeaderResponse().renderCSSReference(reference);
 johan



 On Nov 9, 2007 1:55 PM, German Morales [EMAIL PROTECTED]
 wrote:

 version 1.3.0-beta4.

 I insist that the problem must be something different, perhaps in the
 way
 i pretend it to work. I know about the ResourceStreamLocator, and as i
 tell it works perfectly for the HTML. The difference is that from my
 class
 the framework looks automatically for the corresponding HTML, but how
 should it work for the CSS?

 Should i declare it in the code?

   // on renderHead
   cResponse.getHeaderResponse().renderCSSReference(new
 ResourceReference(MyPage.class, style.css));

 or how?

 What i'm doing is very simple... i'm forcing (for testing) a call to
 Session.setStyle(whatever), then i have MyPage.html and
 MyPage_whatever.html (which works fine) and then style.css and
 style_whatever.css (which i expect to be used thanks to the code
 above).

 But when i see the generated html, it comes with the content of
 MyPage_whatever.html, but the header is generated this way:

 link rel=stylesheet type=text/css
 href=resources/path.to.mypage.MyPage/style.css /

 that is, not pointint to style_whatever.css as i expect.

 Thanks for the support,

 German


 It seems that Johan Compagner wrote:
  it should fallback just fine..
  what version of wicket are you using?
 
  Because in the ResourceStreamLocator we do now this:
 
  public IResourceStream locate(final Class clazz, String path, final
 String
  style,
 final Locale locale, final String extension)
   {
// Try the various combinations of style, locale and extension to
 find
// the resource.
ResourceNameIterator iter = new ResourceNameIterator(path, style,
  locale,
  extension);
while (iter.hasNext())
{
 String newPath = (String)iter.next();
 IResourceStream stream = locate(clazz, newPath);
 if (stream != null)
 {
  stream.setLocale(iter.getLocale());
  return stream;
 }
}
return null;
   }
 
  johan
 
 
 
  On Nov 9, 2007 1:11 PM, German Morales [EMAIL PROTECTED]
  wrote:
 
  Hi again,
 
  Also, the problem is not giving the parameters to the
  ResourceReferences,
  if i call the full constructor then the ResourceReference works, but
 the
  problem is that it does not make a look up to see what's available,
 it
  just goes for the full thing. So, if i call the constructor with the
  session locale and style, what it does is search for the file
  style_mystyle_mylocale.css. This is not my intention, what i want it
  that
  that the framework searches for the style_mystyle_mylocale.css, then
 if
  not found fall back to style_mystyle.css, style_mylocale.css,
 style.css
  and so on (i'm not sure of the exact order of look up). So,
 modifying
  the
  constructor or passing the full parameters is not the solution, i
 think.
 
 
  Regards,
 
  German
 
  It seems that Johan Compagner wrote:
if you are creating your own ResourceReferences then you have to
 give
  the
   style and locale to them
   We could enhance the constructors that it does
  Session.get().getLocale()
   and
   Session.get().getStyle()
   if you dont give them..
  
   johan
  
  
  
   On Nov 9, 2007 10:27 AM, German Morales
 [EMAIL PROTECTED]
   wrote:
  
   Hi,
  
   I was thinking (as a last hope) that if this works for the HTMLs,
 i
   could
   provide different HTMLs that point internally to different CSSs,
 and
  it
   should work. But that would be duplicating the HTML just to have
 the
  CSS
   changed, and then it's not a good idea.
  
   Perhaps someone can tell me an official way to have

Re: ResourceReference with locale and style, for CSSs

2007-11-09 Thread German Morales
Yes, at least that's what i see when i ask Firefox to show me the source
of the page.

It seems that Johan Compagner wrote:
 But even with bind() it still shows you the locale in the url?

 On Nov 9, 2007 3:22 PM, German Morales [EMAIL PROTECTED]
 wrote:

 Hi again,

 With your solution, the generated HTML now looks this way:

 link rel=stylesheet type=text/css
 href=resources/path.to.mypage.MyPage/style_mystyle_mylocale.css /

 i don't have style_mystyle_mylocale.css, but only style_mystyle.css

 But it works!

 So it seems that wicket later (when the browser asks for the css) makes
 the corresponding look up.

 Thanks a lot!

 German

 PS: just for the record (if someone reads this later), there was a easy
 typo in the code below. It should be Application.get() and not
 Application.bind().

 It seems that Johan Compagner wrote:
  no as i said before
  you have to create the resourcereference with the locale and the
 style.
  Those are not automatically picked up from the session. If you don't
 give
  them in the constructor
  then both are just null
 
  What you could do is this:
 
  ResourceReference reference = new ResourceReference(MyPage.class,
  style.css,
  locale,style);
  reference.bind(Application.bind());
  cResponse.getHeaderResponse().renderCSSReference(reference);
  johan
 
 
 
  On Nov 9, 2007 1:55 PM, German Morales [EMAIL PROTECTED]
  wrote:
 
  version 1.3.0-beta4.
 
  I insist that the problem must be something different, perhaps in the
  way
  i pretend it to work. I know about the ResourceStreamLocator, and as
 i
  tell it works perfectly for the HTML. The difference is that from my
  class
  the framework looks automatically for the corresponding HTML, but how
  should it work for the CSS?
 
  Should i declare it in the code?
 
// on renderHead
cResponse.getHeaderResponse().renderCSSReference(new
  ResourceReference(MyPage.class, style.css));
 
  or how?
 
  What i'm doing is very simple... i'm forcing (for testing) a call to
  Session.setStyle(whatever), then i have MyPage.html and
  MyPage_whatever.html (which works fine) and then style.css and
  style_whatever.css (which i expect to be used thanks to the code
 above).
 
  But when i see the generated html, it comes with the content of
  MyPage_whatever.html, but the header is generated this way:
 
  link rel=stylesheet type=text/css
  href=resources/path.to.mypage.MyPage/style.css /
 
  that is, not pointint to style_whatever.css as i expect.
 
  Thanks for the support,
 
  German
 
 
  It seems that Johan Compagner wrote:
   it should fallback just fine..
   what version of wicket are you using?
  
   Because in the ResourceStreamLocator we do now this:
  
   public IResourceStream locate(final Class clazz, String path, final
  String
   style,
  final Locale locale, final String extension)
{
 // Try the various combinations of style, locale and extension to
  find
 // the resource.
 ResourceNameIterator iter = new ResourceNameIterator(path, style,
   locale,
   extension);
 while (iter.hasNext())
 {
  String newPath = (String)iter.next();
  IResourceStream stream = locate(clazz, newPath);
  if (stream != null)
  {
   stream.setLocale(iter.getLocale());
   return stream;
  }
 }
 return null;
}
  
   johan
  
  
  
   On Nov 9, 2007 1:11 PM, German Morales
 [EMAIL PROTECTED]
   wrote:
  
   Hi again,
  
   Also, the problem is not giving the parameters to the
   ResourceReferences,
   if i call the full constructor then the ResourceReference works,
 but
  the
   problem is that it does not make a look up to see what's
 available,
  it
   just goes for the full thing. So, if i call the constructor with
 the
   session locale and style, what it does is search for the file
   style_mystyle_mylocale.css. This is not my intention, what i want
 it
   that
   that the framework searches for the style_mystyle_mylocale.css,
 then
  if
   not found fall back to style_mystyle.css, style_mylocale.css,
  style.css
   and so on (i'm not sure of the exact order of look up). So,
 modifying
   the
   constructor or passing the full parameters is not the solution, i
  think.
  
  
   Regards,
  
   German
  
   It seems that Johan Compagner wrote:
 if you are creating your own ResourceReferences then you have
 to
  give
   the
style and locale to them
We could enhance the constructors that it does
   Session.get().getLocale()
and
Session.get().getStyle()
if you dont give them..
   
johan
   
   
   
On Nov 9, 2007 10:27 AM, German Morales
  [EMAIL PROTECTED]
wrote:
   
Hi,
   
I was thinking (as a last hope) that if this works for the
 HTMLs,
  i
could
provide different HTMLs that point internally to different
 CSSs,
  and
   it
should work. But that would be duplicating the HTML just to
 have
  the
   CSS
changed, and then it's not a good idea.
   
Perhaps someone can tell me an official way to have localized

Re: ResourceReference with locale and style, for CSSs

2007-11-09 Thread German Morales
1.3.0 beta 4

It seems that Johan Compagner wrote:
 I think i asked this before, but what version of wicket??

 Normally (in the current wicket 1.3 buids) a ResourceReference to a
 PackageResource will fallback to the real locale the PackageResource is
 loaded
 from after the ResourceReference is binded.

 johan

 On Nov 9, 2007 3:34 PM, German Morales [EMAIL PROTECTED]
 wrote:

 Yes, at least that's what i see when i ask Firefox to show me the source
 of the page.

 It seems that Johan Compagner wrote:
  But even with bind() it still shows you the locale in the url?
 
  On Nov 9, 2007 3:22 PM, German Morales [EMAIL PROTECTED]
  wrote:
 
  Hi again,
 
  With your solution, the generated HTML now looks this way:
 
  link rel=stylesheet type=text/css
  href=resources/path.to.mypage.MyPage/style_mystyle_mylocale.css /
 
  i don't have style_mystyle_mylocale.css, but only style_mystyle.css
 
  But it works!
 
  So it seems that wicket later (when the browser asks for the css)
 makes
  the corresponding look up.
 
  Thanks a lot!
 
  German
 
  PS: just for the record (if someone reads this later), there was a
 easy
  typo in the code below. It should be Application.get() and not
  Application.bind().
 
  It seems that Johan Compagner wrote:
   no as i said before
   you have to create the resourcereference with the locale and the
  style.
   Those are not automatically picked up from the session. If you
 don't
  give
   them in the constructor
   then both are just null
  
   What you could do is this:
  
   ResourceReference reference = new ResourceReference(MyPage.class,
   style.css,
   locale,style);
   reference.bind(Application.bind());
   cResponse.getHeaderResponse().renderCSSReference(reference);
   johan
  
  
  
   On Nov 9, 2007 1:55 PM, German Morales
 [EMAIL PROTECTED]
   wrote:
  
   version 1.3.0-beta4.
  
   I insist that the problem must be something different, perhaps in
 the
   way
   i pretend it to work. I know about the ResourceStreamLocator, and
 as
  i
   tell it works perfectly for the HTML. The difference is that from
 my
   class
   the framework looks automatically for the corresponding HTML, but
 how
   should it work for the CSS?
  
   Should i declare it in the code?
  
 // on renderHead
 cResponse.getHeaderResponse().renderCSSReference(new
   ResourceReference(MyPage.class, style.css));
  
   or how?
  
   What i'm doing is very simple... i'm forcing (for testing) a call
 to
   Session.setStyle(whatever), then i have MyPage.html and
   MyPage_whatever.html (which works fine) and then style.css and
   style_whatever.css (which i expect to be used thanks to the code
  above).
  
   But when i see the generated html, it comes with the content of
   MyPage_whatever.html, but the header is generated this way:
  
   link rel=stylesheet type=text/css
   href=resources/path.to.mypage.MyPage/style.css /
  
   that is, not pointint to style_whatever.css as i expect.
  
   Thanks for the support,
  
   German
  
  
   It seems that Johan Compagner wrote:
it should fallback just fine..
what version of wicket are you using?
   
Because in the ResourceStreamLocator we do now this:
   
public IResourceStream locate(final Class clazz, String path,
 final
   String
style,
   final Locale locale, final String extension)
 {
  // Try the various combinations of style, locale and extension
 to
   find
  // the resource.
  ResourceNameIterator iter = new ResourceNameIterator(path,
 style,
locale,
extension);
  while (iter.hasNext())
  {
   String newPath = (String)iter.next();
   IResourceStream stream = locate(clazz, newPath);
   if (stream != null)
   {
stream.setLocale(iter.getLocale());
return stream;
   }
  }
  return null;
 }
   
johan
   
   
   
On Nov 9, 2007 1:11 PM, German Morales
  [EMAIL PROTECTED]
wrote:
   
Hi again,
   
Also, the problem is not giving the parameters to the
ResourceReferences,
if i call the full constructor then the ResourceReference
 works,
  but
   the
problem is that it does not make a look up to see what's
  available,
   it
just goes for the full thing. So, if i call the constructor
 with
  the
session locale and style, what it does is search for the file
style_mystyle_mylocale.css. This is not my intention, what i
 want
  it
that
that the framework searches for the style_mystyle_mylocale.css,
  then
   if
not found fall back to style_mystyle.css, style_mylocale.css,
   style.css
and so on (i'm not sure of the exact order of look up). So,
  modifying
the
constructor or passing the full parameters is not the solution,
 i
   think.
   
   
Regards,
   
German
   
It seems that Johan Compagner wrote:
  if you are creating your own ResourceReferences then you
 have
  to
   give
the
 style and locale to them
 We could enhance the constructors that it does

Re: ResourceReference with locale and style, for CSSs

2007-11-08 Thread German Morales
Hi johan,

The problem is that the file is there... just that it doesn't seem to be
looking for it.

If i force the full constructor:

new ResourceReference(MyPage.class, style.css, getLocale(), getStyle())

all works, so the file is correcly found and the name is correct.

The problem is when i don't set the locale and style explicitely (as it is
supposed to be done):

new ResourceReference(MyPage.class, style.css)

then it doesn't find the file. Actually i think it doesn't even try to
find it, since as i mention i put a breakpoint in
ResourceReference#setStyle() and nobody is calling it. So later internal
code to load the resource uses style and locale with null values.

I'm not sure if there's something i'm missing, or how it is supposed to be
done.

Thanks,

German


It seems that Johan Compagner wrote:
 they locale and style are used to search for it yes
 they are not forced.. What do you mean with that?
 If the file with that style and locale isn't there it will fallback

 johan


 On Nov 7, 2007 10:50 PM, German Morales [EMAIL PROTECTED]
 wrote:

 Hi all,

 I'm having trouble with localized and styled CSSs.

 Everything works alright with HTML. For example, wicket finds
 MyPage_mystyle.html instead of MyPage.html if i've called
 session.setStyle(mystyle). But for CSS i can't get it working.

 i've tried different approaches like:

   // inside the page constructor
   add(HeaderContributor.forCss(new ResourceReference(MyPage.class,
 style.css)));


   // inside renderHead
   cResponse.getHeaderResponse().renderCSSReference(new
 ResourceReference(MyPage.class, style.css));


 None of this worked for me. However, it works if I call the full
 constructor of ResourceReference:

 new ResourceReference(MyPage.class, style.css, getLocale(),
 getStyle())

 But i'm not supposed to do that, because then the Locale and Style are
 forced, and i want this only if the file is present. I know some
 ResourceStreamLocator should be involved in the process, but i don't
 know
 how. I see in the ResourceReference javadoc that the framework should be
 calling the setStyle() method, but i debugged it and it doesn't happen.

 What am i doing wrong?

 Thanks in advance,

 German



 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]






-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: ResourceReference with locale and style, for CSSs

2007-11-08 Thread German Morales
Hi,

I use it inside a page.

I've tried...

   // inside the page constructor
   add(HeaderContributor.forCss(new ResourceReference(MyPage.class,
style.css)));

and

   // inside renderHead
   cResponse.getHeaderResponse().renderCSSReference(new
ResourceReference(MyPage.class, style.css));


And I don't want to set the style and locale explicitely. What i want is
to deliver the application to a customer, and, if he wants, he adds the
customized page for a locale or style by itself (he could set the style
with a parameter or whatever). And as far as i understand the wicket
approach, that's how it should work automatically. In fact it works
perfecly when i do it for the html of the same page. The difference is
that the html is handled in other way (the framework does it) and when i
try to do it for the CSS of the page i do it (and it doesn't work). So
there must be something i'm not doing properly.

Or, how should be the way to provide styled CSSs, there is another aproach?

thanks and bye,

German

It seems that Eelco Hillenius wrote:
 The problem is that the file is there... just that it doesn't seem to be
 looking for it.

 If i force the full constructor:

 new ResourceReference(MyPage.class, style.css, getLocale(),
 getStyle())

 all works, so the file is correcly found and the name is correct.

 The problem is when i don't set the locale and style explicitely (as it
 is
 supposed to be done):

 new ResourceReference(MyPage.class, style.css)

 then it doesn't find the file. Actually i think it doesn't even try to
 find it, since as i mention i put a breakpoint in
 ResourceReference#setStyle() and nobody is calling it. So later internal
 code to load the resource uses style and locale with null values.

 How do you use the resource reference? I think the class was designed
 in such a way that the components that use it (Image for instance) are
 responsible for setting the appropriate locale/ style 'just in time',
 so that switching locales etc works.

 Eelco

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



ResourceReference with locale and style, for CSSs

2007-11-07 Thread German Morales
Hi all,

I'm having trouble with localized and styled CSSs.

Everything works alright with HTML. For example, wicket finds
MyPage_mystyle.html instead of MyPage.html if i've called
session.setStyle(mystyle). But for CSS i can't get it working.

i've tried different approaches like:

   // inside the page constructor
   add(HeaderContributor.forCss(new ResourceReference(MyPage.class,
style.css)));


   // inside renderHead
   cResponse.getHeaderResponse().renderCSSReference(new
ResourceReference(MyPage.class, style.css));


None of this worked for me. However, it works if I call the full
constructor of ResourceReference:

new ResourceReference(MyPage.class, style.css, getLocale(), getStyle())

But i'm not supposed to do that, because then the Locale and Style are
forced, and i want this only if the file is present. I know some
ResourceStreamLocator should be involved in the process, but i don't know
how. I see in the ResourceReference javadoc that the framework should be
calling the setStyle() method, but i debugged it and it doesn't happen.

What am i doing wrong?

Thanks in advance,

German



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: AutoCompleteTextfield - how to populate two input fields

2007-10-11 Thread German Morales
Hi,

Sorry, i'm a little late with my response.
Did the suggestion by Nino work?

If it works, i would like to know more details about it.

If not, we already had a somehow similar problem (Swiss addresses), and we
have a different solution already working. Perhaps it can help you too.

Regards,

German


It seems that Nino Saturnino Martinez Vazquez Wael wrote:
 NP, waiting with excitement to hear if it works:)

 Oliver Lieven wrote:
 Thanks allot for your efforts and detailed answer! Sounds good, I'll
 give it
 a try.


 Nino.Martinez wrote:

 No what I meant was that when a user selects something in one  of your
 auto complete fields  they'll automatickly select something in both,
 might have been a little scares on information:

 IModel commonModel=new Model();


 AbstractModel() Text=new AbstractModel(){

 getObject{
 return commonModel.getObject.Text;
 }
 setObject(obj){
 commonModel.setObject(obj)
 }

 }


 AbstractModel() name=new AbstractModel(){

 getObject{
 return commonModel.getObject.name;
 }
 setObject(obj){
 commonModel.setObject(obj)
 }

 }



 AutoCompleteTextField phoneName = new AutoCompleteTextField(
 phoneName, name,
 new BestEffortRendererAutoCompleteRenderer()) {
 @Override
 protected Iterator getChoices(String input) {

 return findItems(input);
 }
 };


 AutoCompleteTextField phoneSeries = new AutoCompleteTextField(
 phoneName, text,
 new BestEffortRendererAutoCompleteRenderer()) {
 @Override
 protected Iterator getChoices(String input) {

 return findItems(input);
 }
 };

 And ofcourse you need to add the other completefield to the
 ajaxresponse...

 Hope this pseudo code works a little better... Was on my way out the
 door before...


 Oliver Lieven wrote:

 Hi Nino,
 thanks for your fast reply. Yes, a shared PropertyModel would help to
 keep
 both fields synchronized.

 I still can't see how this could help me to determine the value
 selected
 by
 the user.
 The AutoComplete works like

 1. getChoices() is called to populate the autocomplete list with my
 zipcode
 - city options
 2. when user selects a value from the autocomplete list, the
 corresponding
 field is set with the textvalue (e.g. the 'city' field is filled
 with
 the
 city's name)
 3. because of this update, the city-field's
 AjaxFormComponentUpdatingBehavior.onUpdate() is called
 4. in onUpdate() the getConvertedInput() method returns the city name,
 which
 is insufficient to determine the corresponding zipcode (because of the
 n:1
 relation (city may have many zipcodes)).

 So I'm still looking for a way to determine the exact combination
 selected
 by the user...

 regards,
 Oliver


 Nino.Martinez wrote:


 Quick answer, why not use property models and use both in the fiields
 you mention?

 Oliver Lieven wrote:


 Hi,

 in an address edit panel I've got the two AutoCompleteText fields
 'zipcode'
 and 'city'.

 When a users begins typing into the zipcode-field, the autocomplete
 shows
 up
 and offers valid zipcode - city combinations. After selecting a
 value
 from
 the autocomplete the 'zipcode' is set. Same for 'city' field, i.e.
 after
 selecting a zipcode - city from the city's autocomplete the
 city-field
 is set accordingly.
 (Thanks for the great autocomplete-support in Wicket which allows
 separation
 of displayvalue and textvalue!)

 Now to my question: after selection of a zipcode - city
 combination
 from
 either autocomplete list I would like to set both fields (zipcode
 and
 city).
 I already attached an AjaxFormComponentUpdatingBehavior which gets
 called
 after a selection in the autocomplete list, but it just gets the
 zipcode/city currently set.
 Since the zipcode-city relation is 1:n (e.g. Berlin has many
 zipcodes)
 I'm
 wondering if there is a way to access the full selected value (and
 not
 only
 the AbstractAutoCompleteTextRenderer.textvalue set).


 Thanks for any help and tips!
 Oliver





 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]







 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]







 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: AutoCompleteTextfield - how to populate two input fields

2007-10-11 Thread German Morales
Hi again,

Yes, we have something similar to what you describe in your point 2.

The only difference is that we have other structure. What we have is the
following:

-Each locality has an internal ID, a Zip Code, a City and a (swiss) kanton.

-in the html we have a Hidden, which stores the internal ID, and 1 (only)
TextField, which shows Zip Code + City + Canton (For example: 8052
Seebach, ZH).

-then we have an extension as you mention (AutoCompleteTextField,
Renderer, Behavior, JavaScript), which is already working with this
schema. It also contains many fixes over the original
autocompletetextfield (perhaps originated from the extra behavior?).

If this approach is good for you, i can send you our version, plus some
example usages.

Regards,

German


It seems that Oliver Lieven wrote:

 Hi,

 thanks for your answer.

 No, solution didn't work as supposed, mainly because the AutoComplete
 fills
 the input field in the browser with the data (in my case either zipcode or
 city), but doesn't update the model.

 To update the model I have to attach some Ajax...Behavior, but this is
 called with the data put into the textfield (i.e. either the selected
 zipcode put into the zipcode field by the autocomplete, *or* the selected
 city from the city field). In the Ajax...Behavior's onUpdate()-method
 neither the city nor the zipcode are enough to determine the value to use
 to
 update the related field.

 So I had two other ideas:

 1. in my autocomplete-list I set the textvalue to the id of a
 zipcode-city combination. When the user selects from the
 autocomplete-list, this id is written into the corresponding input-field.
 The attached AjaxOnChangeBehavior now gets this id, determines the
 zipcode-city, and updates the city and the zipcode field. This works, but
 looks a little strange to the user (e.g. selection of 71254 Ditzingen
 from
 autocomplete-list writes the id (1223) into the zipcode-field, this
 issues
 the Ajax-call, which updates both fields with the correct data, i.e.
 zipcode=71254, city=Ditzingen). As I said, works but not pretty.

 2. So I'm currently extended the AutoCompleteTextField, ...Renderer,
 ...Behavior, ..JavaScript to accept a second, related field in its
 constructor. I then attach two attributes to the autocomplete-list entries
 (say textvalue and textvalue2), and modified the JavaScript to update both
 fields. This seems to me the best approach to my specific problem, and
 seems
 to work as intended.

 Hope my answer was not to confusing...
 regards,
 Oliver


 German Morales wrote:

 Hi,

 Sorry, i'm a little late with my response.
 Did the suggestion by Nino work?

 If it works, i would like to know more details about it.

 If not, we already had a somehow similar problem (Swiss addresses), and
 we
 have a different solution already working. Perhaps it can help you too.

 Regards,

 German


 It seems that Nino Saturnino Martinez Vazquez Wael wrote:
 NP, waiting with excitement to hear if it works:)

 Oliver Lieven wrote:
 Thanks allot for your efforts and detailed answer! Sounds good, I'll
 give it
 a try.


 Nino.Martinez wrote:

 No what I meant was that when a user selects something in one  of
 your
 auto complete fields  they'll automatickly select something in both,
 might have been a little scares on information:

 IModel commonModel=new Model();


 AbstractModel() Text=new AbstractModel(){

 getObject{
 return commonModel.getObject.Text;
 }
 setObject(obj){
 commonModel.setObject(obj)
 }

 }


 AbstractModel() name=new AbstractModel(){

 getObject{
 return commonModel.getObject.name;
 }
 setObject(obj){
 commonModel.setObject(obj)
 }

 }



 AutoCompleteTextField phoneName = new AutoCompleteTextField(
 phoneName, name,
 new BestEffortRendererAutoCompleteRenderer()) {
 @Override
 protected Iterator getChoices(String input) {

 return findItems(input);
 }
 };


 AutoCompleteTextField phoneSeries = new AutoCompleteTextField(
 phoneName, text,
 new BestEffortRendererAutoCompleteRenderer()) {
 @Override
 protected Iterator getChoices(String input) {

 return findItems(input);
 }
 };

 And ofcourse you need to add the other completefield to the
 ajaxresponse...

 Hope this pseudo code works a little better... Was on my way out the
 door before...


 Oliver Lieven wrote:

 Hi Nino,
 thanks for your fast reply. Yes, a shared PropertyModel would help
 to
 keep
 both fields synchronized.

 I still can't see how this could help me to determine the value
 selected
 by
 the user.
 The AutoComplete works like

 1. getChoices() is called to populate the autocomplete list with my
 zipcode
 - city options
 2. when user selects a value from the autocomplete list, the
 corresponding
 field is set with the textvalue (e.g. the 'city' field is filled
 with
 the
 city's name)
 3. because