You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by britter <be...@codecentric.de> on 2013/10/21 09:47:06 UTC

Problem when adding component with PackagedResourceReference during submit

Hi,

I'm having a problem with a component that uses a PackagedResourceReference.
Here is the setup:

I'm using Wicket 1.5.10 with wiquery 1.5.7. I've extended DatePicker<T> to
add a custom image fur the widget. The relevant part f the constructor looks
like this:

PackageResourceReference pcgRef = new
PackageResourceReference(BrDatePickerField.class, "calendar.gif");
String url = urlFor(pcgRef, null).toString();
setButtonImage(url);

Now I'm using the BrDatePickerField in a RepeatingView. It is used for users
to submit cost points. For example "On Jan/31/2013: 34,23$". This view has a
button that adds additional rows. The button just adds a new item to the
list that is shown by the RepeatingView.
When the View is rendered initially the calendar.gif shows up correctly for
all rows that have already been added to the data store:
../resource/com.mypackage.wutils.BrDatePickerField/calendar-ver-1378812639389.gif

However, if I add a new row the icon will not show up in the new row. The
url for the new row is:
./resource/de.brunata.online.wutils.BrDatePickerField/calendar-ver-1378812639389.gif

I believe this has something to do with the request URL, because I know that
the UrlRender uses the client Url somewhere. If I debug the constructor of
the BrDatePickerField, I can see that in the inital call 
getRequest().getClientUrl() =
wicket/bookmarkable/com.mypackage.PageThatUsesBrDatePickerField

If I press the add Row button it will become:
getRequest().getClientUrl() = wicket/page?15-1.IFormSubmitListener-fHnKosten

I have already tried to use a context relative resource, but this doesn't
help. I've also tried to hack the constructor of the BrDatePickerField by
adding a ../ if it is missing, but this will break the icon on other pages.
Can anybody help here?

TIA!

Benedikt



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Problem-when-adding-component-with-PackagedResourceReference-during-submit-tp4661896.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Problem when adding component with PackagedResourceReference during submit

Posted by britter <be...@codecentric.de>.
Hello Martin,

thanks for your reply. The setButtonImage method is defined in
org.odlabs.wiquery.ui.datepicker.DatePicker<T>, see here:
http://code.google.com/p/wiquery/source/browse/trunk/src/main/java/org/odlabs/wiquery/ui/datepicker/DatePicker.java?r=553

My BrDatePickerField looks something like this:

public class BrDatePickerField<T> extends DatePicker<T> {

   public BrDatePickerField(String id, IModel<T> model) {
      super(id, model);
      // do some stuff with model, add validators etc.

      PackageResourceReference pcgRef = new
PackageResourceReference(BrDatePickerField.class, "calendar.gif");
      String url = urlFor(pcgRef, null).toString();
      setButtonImage(url); // inherited from DatePicker<T>
   }

}

Now I've just realized, that the hole process of adding new rows to the view
is implemented manually. I guess I'll have to change this so that a
RefeshingView is used. If this doesn't work, I'll come back here.

Thanks!
Benedikt



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Problem-when-adding-component-with-PackagedResourceReference-during-submit-tp4661896p4661900.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Problem when adding component with PackagedResourceReference during submit

Posted by Martin Grigorov <mg...@apache.org>.
Hi,


On Mon, Oct 21, 2013 at 10:47 AM, britter <be...@codecentric.de>wrote:

> Hi,
>
> I'm having a problem with a component that uses a
> PackagedResourceReference.
> Here is the setup:
>
> I'm using Wicket 1.5.10 with wiquery 1.5.7. I've extended DatePicker<T> to
> add a custom image fur the widget. The relevant part f the constructor
> looks
> like this:
>
> PackageResourceReference pcgRef = new
> PackageResourceReference(BrDatePickerField.class, "calendar.gif");
> String url = urlFor(pcgRef, null).toString();
> setButtonImage(url);
>

The problem is that you generate the url manually against some base url and
later it doesn't work against another base url.
Where #setButtonImage(String) method is defined ?
Can you make it lazy/dynamic or use a ResourceReference instead ?
Show us the related code if you need help with that.


>
> Now I'm using the BrDatePickerField in a RepeatingView. It is used for
> users
> to submit cost points. For example "On Jan/31/2013: 34,23$". This view has
> a
> button that adds additional rows. The button just adds a new item to the
> list that is shown by the RepeatingView.
> When the View is rendered initially the calendar.gif shows up correctly for
> all rows that have already been added to the data store:
>
> ../resource/com.mypackage.wutils.BrDatePickerField/calendar-ver-1378812639389.gif
>
> However, if I add a new row the icon will not show up in the new row. The
> url for the new row is:
>
> ./resource/de.brunata.online.wutils.BrDatePickerField/calendar-ver-1378812639389.gif
>
> I believe this has something to do with the request URL, because I know
> that
> the UrlRender uses the client Url somewhere. If I debug the constructor of
> the BrDatePickerField, I can see that in the inital call
> getRequest().getClientUrl() =
> wicket/bookmarkable/com.mypackage.PageThatUsesBrDatePickerField
>
> If I press the add Row button it will become:
> getRequest().getClientUrl() =
> wicket/page?15-1.IFormSubmitListener-fHnKosten
>
> I have already tried to use a context relative resource, but this doesn't
> help. I've also tried to hack the constructor of the BrDatePickerField by
> adding a ../ if it is missing, but this will break the icon on other pages.
> Can anybody help here?
>
> TIA!
>
> Benedikt
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Problem-when-adding-component-with-PackagedResourceReference-during-submit-tp4661896.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>