I attached a quickstart here but I'm not sure attachments work on this list. Let me know how to send the file if that fails.
  Scott

On 5/6/2011 12:17 PM, Igor Vaynberg wrote:
having a working quickstart project would help.

-igor

On Fri, May 6, 2011 at 9:13 AM, Scott Reed<sr...@avacoda.com>  wrote:
I was not able to get the custom onpagebeforeshow event handling to work.
I have fallen back to using the standard onclick event handling. I see the
update code being executed in the ajax event handler but the changes do not
show up on the subpage.

Below is the core of my most recent approach. The RefreshingView is the
element I am trying to update on the subpage. detailSubpage is a
WebMarkupContainer for the subpage that contains the RefreshingView table.
If it would help I can supply all the code (total 200 lines).

<!-- Detail page used when subpage item is selected from the subpages list
-->
<div data-role='page' wicket:id="detailSubpage" id="detailSubpage">
<div data-role='content' wicket:id="detailContent"
            style='height: 100%'>
<table wicket:id="detailTable" id="detailTable">
<tr>
<td>Name</td>
<td>&nbsp;</td>
<td wicket:id="name" style='font-weight: bold;'>...</td>
</tr>
<tr>
<td>Status</td>
<td>&nbsp;</td>
<td wicket:id="status" style='font-weight: bold;'>...</td>
</tr>
</table>
</div>
</div>

  private class FooList extends RefreshingView<Foo>
  {
    FooDetailContainer detailSubpage;

    public FooList( String id, FooListModel model, FooDetailContainer
detailSubpage )
    {
      super( id, model );
      this.detailSubpage = detailSubpage;
    }

    @Override
    protected void populateItem( Item<Foo>  item )
    {
      final Foo foo = item.getModelObject();
      addFooItem( item, foo );
    }

    private void addFooItem( Item<Foo>  item, final Foo foo )
    {
      Label fooNameLabel = new Label( "subpageName", foo.getName());
      item.add( fooNameLabel );
      item.add( new FooClickBehavior( "onclick", foo ));
    }

    /**
     * records most recently selected foo
     */
    private class FooClickBehavior extends AjaxEventBehavior
    {
      Foo foo;
      public FooClickBehavior( String event, Foo foo )
      {
        super( event );
        this.foo = foo;
      }
      public void onEvent( AjaxRequestTarget target )
      {
        //populate foo detail page
        detailSubpage.getNameLabel().setDefaultModelObject( foo.getName() );
        detailSubpage.getStatusLabel().setDefaultModelObject( foo.getStatus()
);
        detailSubpage.getStatusLabel().add( new AttributeModifier( "style",
true, new Model( "font-weight:bold;" )));

// commented due to error:
// Wicket.Ajax.Call.processEvaluation: Exception evaluating javascript:
cannot call methods on listview prior to initialization; attempted to call
method 'refresh'
//        // refresh detail page table
//        String js = "$('#detailTable').listview('refresh')";
//        target.appendJavascript( js );
      }
    }

    @Override
    protected Iterator<IModel<Foo>>  getItemModels()
    {
      return new FooListModel().load().iterator();
    }
  }


On 5/4/2011 7:20 PM, Igor Vaynberg wrote:
something like this may help you.

AbstractDefaultAjaxBehavior b=new AbstractDefaultAjaxBehavior() {
   respond(target) { // handle ajax callback }
};

div.add(b);
String script=b.getCallbackScript();

what you have in the script variable is a javascript fragment which
will invoke the server-side callback. you can now write that out into
the head yourself using IHeaderContributor and wire it into jquery's
callback.

-igor


On Wed, May 4, 2011 at 3:56 PM, Scott Reed<sr...@avacoda.com>    wrote:
I tried doing this using the onclick event of the list item but there
were a
couple of problems. The biggest problem is that there may be hundreds of
items in the list and inserting an ajax call in each item increases the
page
size too much for a mobile app. Another problem is that the id of the
"detail page" component is modified by Wicket when I add ajax behaviors
to
it so the href in the item link is incorrect. I figured out how to handle
this by changing the href using getMarkupId() but that kind of
maintenance
nightmare hacking turned me off to the whole approach. Finally I couldn't
figure out how to get it to go to the detail page after I updated it - it
just went back to the home page.

I tried adding an AjaxEventBehavior to the target div but the server-side
event handler is never called. I don't understand how a custom event can
be
caught by the ajax engine unless there is js to tell it to do so and I
don't
see that Wicket has added any js in the page source to do that. If I knew
how to tell the ajax engine to look for the custom javascript event then
that approach would probably work.

On 5/4/2011 6:35 PM, Igor Vaynberg wrote:
can you not do it the other way around? have the link that goes to
detail be a wicket ajax link which then repaints the content div and
tells jquery that it did so?

otherwise what you can do is add an ajaxeventbehavior for that even to
the content div or whatever div receives it, or wire it in directly to
window, and repaint the content div inside the behavior's handler.

-igor


On Wed, May 4, 2011 at 3:27 PM, Scott Reed<sr...@avacoda.com>      wrote:
I want to update the models for the component's children and refresh
it.

This app has a list on the "home page". Selecting one of the list items
causes a transition to the "detail page". During that transition the
pagebeforeshow event fires and then the page is displayed. When the
pagebeforeshow event fires, I want to update the page content elements
with
details of the selected item. (As you may know, in jQuery Mobile these
"pages" are divs with data-roll="page".)

On 5/4/2011 6:13 PM, Igor Vaynberg wrote:
can you explain a bit more of what you want to happen when this
javascript event is fired?

-igor

On Wed, May 4, 2011 at 3:05 PM, Scott Reed<sr...@avacoda.com>
  wrote:
Certain jQuery Mobile components can trigger a custom javascript
event,
"pagebeforeshow", which I want to handle on the server. I am new to
this
list and to Wicket and have not been able to find any documentation
or
examples that show how this could be done.|I would appreciate any
help
in
figuring this out.
  Thanks,
    Scott
|

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

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


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

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


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

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


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


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

Reply via email to