Maurice,
Thanks a lot for your help, but you still miss the
target!
>
> Now all we need to do is extend/override onClickLink
> or make or own
> implementation of Link, so that the javascript
> function datePopup() is
> triggered. There are several ways to do this and I
> am confident you will
> accomplish that part on your own.
Just that I need!
Seems I have to use handleComponentTag() but I dont
understand how and where! I have tried to override
this method without success. An I think there are some
interfernce with getPopupJavaScript() method :
....
public OnClickLink(String name, Serializable
object, String expression)
{
super(name, object, expression);
}
protected final void handleComponentTag(final
ComponentTag tag)
{
// Add simple javascript on click handler that
links to this
// link's linkClicked method
final String url = getURL().replaceAll("&",
"&");
final PopupSettings popupSettings =
getPopupSettings();
if (popupSettings != null)
{
popupSettings.setTarget("'" + url + "'");
String popupScript =
popupSettings.getPopupJavaScript();
popupScript = popupScript.replaceAll("&",
"&");
tag.put("onclick", popupScript);
}
else
{
tag.put("onclick", "location.href='" + url +
"';");
}
}
...
What do you think?
Thanks again
Antonio
--- Maurice Marrink <[EMAIL PROTECTED]>
wrote:
> Ok,
>
> If you already have this working then it should be
> relatively easy to
> send the textfield value without submitting the
> form.
> Be ready for some dirty work though.
> Here is what you need, we'll get to how you can do
> it later ;)
> - when the link /icon is clicked we need to get the
> field value
> - then we need to trigger the popup with the value
>
> Too get the value we need some javascript:
> document.getElementById('text field id here').value
>
> Then we need to trigger the popup I recommend
> something like:
> OnClickLink onClickLink = new OnClickLink("link")
> {
> public void linkClicked()
> {
> RequestCycle cycle = RequestCycle.get();
> PageParameters params = new PageParameters();
> cycle.setPage(cycle.getPageFactory().newPage
> (DatePickerPopupPage.class, params));
> }
> };
> onClickLink.setPopupSettings(makePopup(index));
> //you probably need an
> index if you are going to use multiple datepickers
> on the same page, to
> keep track
>
> private PopupSettings makePopup(int index)
> {
> PopupSettings popup = new PopupSettings(false,
> false,
> false, false, false);
> popup.setHeight(500);
> popup.setWidth(560);
> popup.setLocation(500, 200);
> popup.setWindowName("some name_" + index);
> popup.setFocus(true);
> return popup;
> }
>
> Now to keep everything reusable we need to add some
> dynamic
> javascripting, I use the following trick to do that:
>
> private class JavaScriptPanel extends Panel
> {
> /**
> * Construct.
> * @param componentName
> */
> public JavaScriptPanel(String componentName, int
> componentIndex)
> {
> super(componentName);
> add(new Label("script", new IModel()
> {
> public Object getObject()
> {
> int index = componentIndex;
> OnClickLink link = (OnClickLink)
> parent.get("link");
> String url =
> getRequestCycle().urlFor(link, ILinkListener.class);
> PopupSettings popup = makePopup(index);
> popup.setTarget("'" +
> url.replaceAll("&", "&") + "'+'&param1='+
> document.getElementById('text field id
> here').value");
> StringBuffer buffer = new StringBuffer(
> "<script
> language=\"JavaScript1.1\">\r\n").append(
> "\t<!--\r\n\t\tfunction
> datePopup()\r\n\t\t{\r\n").append("\t\t\t")
>
.append(popup.getPopupJavaScript()).append("\r\n\t\t}\r\n\t//-->\r\n</sc
> ript>");
> return buffer.toString();
> }
> public void setObject(Object object)
> {
> // not important
> }
> }).setShouldEscapeModelStrings(false));
> }
> }
>
> Now all we need to do is extend/override onClickLink
> or make or own
> implementation of Link, so that the javascript
> function datePopup() is
> triggered. There are several ways to do this and I
> am confident you will
> accomplish that part on your own.
>
> What exactly did we do here?
> The following should happen:
> The link is clicked this triggers a javascript
> function that: A gets the
> value, B dynamicly adjusts an url, C opens the url
> in a popup.
> Wicket will now trigger a call to your onclick
> function which simply
> tells it to render a page.
>
> All you have to do now is get the request parameter
> "param1" and use it
> as input.
>
> Please Note that this code is not tested (frankly
> I'll be surprised if
> it works in 1 go) but it should give you a general
> idea of what to do.
> Also in my own code I use subclasses of both
> onclicklink and
> popupsetting, I don't think you need my classes and
> I tried to make the
> code not use any of my adaptations, but if you come
> across something the
> wicket api does not recognize don't hesitate to ask.
>
> Maurice
>
>
> -----Oorspronkelijk bericht-----
> Van: Antonio Casula [mailto:[EMAIL PROTECTED]
> Verzonden: vrijdag 11 februari 2005 18:02
> Aan: [email protected]
> Onderwerp: RE: [Wicket-user] onClick event
>
> Probably my question it's not so clear ...
> I am already opening a popup with a
> BookmarkablePageLink as you can see. I need to get
> the
> content of the textfield when the user click the
> link
> before open the popup without submit the form. I
> think
> is possible if there are some opportunity to change
> the javascript code that is invoked by
> BookmarkablePageLink .
> I am able now to fill the textfield from the popup
> with the user selected value but not the opposite!
> I cannot show the actual data from textfield in the
> popup calendar.
>
>
> This is a part of the code of DatePicker:
>
> public final class DatePicker extends Panel {
>
> /**
> * Constructor that uses the provided [EMAIL PROTECTED]
> IModel}as its model. All components have
> * names. A component's name cannot be null.
> * @param name The non-null name of this
> component
> * @param model
> * @throws WicketRuntimeException Thrown if the
> component has been given a null name.
> */
> public DatePicker(String name, IModel model)
> {
> super(name);
> TextField stringInput = new
> TextField("campo",model);
> createUI(stringInput);
> }
>
> ...
> /**
> */
> public DatePicker(String name, IModel model, String
> expression)
> {
> super(name);
> TextField stringInput = new
> TextField("campo",model,expression);
> createUI(stringInput);
> }
>
> private void createUI(TextField field){
> add(field);
> PopupSettings popupSpec = new
>
PopupSettings().setHeight(200).setWidth(265).setLocation(100,100).setSta
> tusBar(false).setWindowName("WCalendar")
> ;
> final BookmarkablePageLink link = new
> BookmarkablePageLink("popupLink",
> DatePickerPopupPage.class);
> link.setPopupSettings(popupSpec);
> link.add(new Image("image4", "cal.gif"));
> add(link);
> }
> }
>
>
=== message truncated ===
__________________________________
Do you Yahoo!?
Take Yahoo! Mail with you! Get it on your mobile phone.
http://mobile.yahoo.com/maildemo
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user