You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Emulator <em...@gmail.com> on 2010/05/18 05:33:18 UTC

click url /submit cross target between iframes

    Hi everyone, I'm using wicket 1.4.8, and IE6(IE 6 request due to project
restriction).
    I have a three pages, Menu(on left side), List(top on the right),
Detail(buttom on the right).
The List page is simply like a bookshelf that shows each book's name. When I
click one of the book on the List. The book's info will be shown on the
Detail page.

    Because of all books' data is coming from database, so I implement my
pageable dataprovider and a custom listview so tha each book presented on
the html table just like <td wicket:id="1"><span
wicket:id="text1"></span></td>

List.page
<form wicket:id="ListForm" target="_detail">
<table  frame="border" rules="none" cellspacing="0px" id="dataView">
    <tr style="background-color:#FF9">
        <th>1st Column</th>
        <th>2nd Column</th>
        <th>3rd Column</th>
        <th>4th Column</th>
    </tr>
    <tr wicket:id="selectList" onclick="ListForm.submit()">
    <td wicket:id="1"><a href="#" wicket:id="link1" target="_detail"><span
wicket:id="text1"></span></a></td>
    <td wicket:id="2"><a href="#" wicket:id="link2" target="_detail"><span
wicket:id="text2"></span></a></td>
    <td wicket:id="3"><a href="#" wicket:id="link3" target="_detail"><span
wicket:id="text3"></span></a></td>
    <td wicket:id="4"><a href="#" wicket:id="link4" target="_detail"><span
wicket:id="text4"></span></a></td>
    </tr>
</table>
</form>

Then I process the above html code as a subclass of Link, process all
onClick/onSubmit. And it would be fine if I just want to show info page on
the List. If I set onClick to setResponsePage(new BookDetailPage(Book aBook,
...other Param));

List.java

void onClick()
{
    setResponsePage(new BookDetailPage(Book aBook, ...other Param));
}

Detail.html
<form wicket:id="EditForm">
    <span wicket:id="booksId"></span>
    <input type="text" wicket:id="booksName"></input>
    <input type="text" wicket:id="booksPublisher"></input>
    <span wicket:id="booksUpdateTime"></span>
    <p></p>
    <input type="submit" wicket:id="btnCommit"></input>
</form>

But what I want is to show book info (BookDetailPage) on the detail page. so
I use 3 iframes to include those 3 pages into one page - book_index, then
process all iframe to wicket class InlineFrame.
The reason of using iframe is to decrease the full-page reload and db
connection that bookshelf uses.

Book_Index.html
<form>
<iframe wicket:id="_iMenu" frameborder="1" framespacing="0" width="20%"
height="100%" align="left"></iframe>
<iframe wicket:id="_iList" frameborder="1" framespacing="0" width="80%"
height="75%" align="top" scrolling="no"></iframe>
<iframe wicket:id="_iDetail" name="_detail" frameborder="1" framespacing="0"
width="80%" height="25%" align="buttom"></iframe>
</form>

Book_Index.java
    Books_Index()
    {
        super();
        add(new InlineFrame("_iMenu", new LeftMenu()));
        FunctionPage master = new FunctionPage(this);

        InlineFrame f_master = new InlineFrame("_iList",master);
        add(f_master);

        DataEditPage detail = new DataEditPage();
        InlineFrame iDetail = new InlineFrame("_iDetail", detail);
        iDetail.setOutputMarkupId(true);
        add(iDetail);

        master.setEditorPage(detail, this);
    }

I've tried to specified form post target, url target on the List.html but
not works.
Or use it on List

ListPage
void onClick()
{
    /* init actions */

    /* target is still remain in self */
     this.RequestCycle().setRequestTarget(new
PageReferenceRequestTarget(detailPage));
     this.setResponsePage(new DetailPage());

    /*  no compatible RequestTarget for InlineFrame*/
     this.RequestCycle().setRequestTarget(detailFrame);
     this.setResponsePage(new DetailPage());
}


Is any way that can set link/post target to the detail frame, or other way I
should do without iframe?

Regards,
Victor Chen

Re: click url /submit cross target between iframes

Posted by Emulator <em...@gmail.com>.
I've solved this problem with a dirty trick by changing the default onclick
string that generted by Link class.

class ChangeTarget extends Link
{

    EditpageLink(String id, String TargetId)
    {
        super(id);
        this._TargetId = TargetId;
    }

    @Override
    public void onComponentTag(ComponentTag tag)
    {
        final String LocationRedirectHack = "window.location.href";
        super.onComponentTag(tag);
        String clickEvent = tag.getAttribute("onclick");
        if(clickEvent.indexOf(LocationRedirectHack)<1)
            try {throw new Exception("Wicket Version Updated, Please modify
this hack!");}
            catch (Exception e) { e.printStackTrace();}
        tag.put("onclick", clickEvent.replace(LocationRedirectHack,
"window.parent."+._TargetId+".location.href"));
    }
}

2010/5/18 Emulator <em...@gmail.com>

>     Hi everyone, I'm using wicket 1.4.8, and IE6(IE 6 request due to
> project restriction).
>     I have a three pages, Menu(on left side), List(top on the right),
> Detail(buttom on the right).
> The List page is simply like a bookshelf that shows each book's name. When
> I click one of the book on the List. The book's info will be shown on the
> Detail page.
>
>     Because of all books' data is coming from database, so I implement my
> pageable dataprovider and a custom listview so tha each book presented on
> the html table just like <td wicket:id="1"><span
> wicket:id="text1"></span></td>
>
> List.page
> <form wicket:id="ListForm" target="_detail">
> <table  frame="border" rules="none" cellspacing="0px" id="dataView">
>     <tr style="background-color:#FF9">
>         <th>1st Column</th>
>         <th>2nd Column</th>
>         <th>3rd Column</th>
>         <th>4th Column</th>
>     </tr>
>     <tr wicket:id="selectList" onclick="ListForm.submit()">
>     <td wicket:id="1"><a href="#" wicket:id="link1" target="_detail"><span
> wicket:id="text1"></span></a></td>
>     <td wicket:id="2"><a href="#" wicket:id="link2" target="_detail"><span
> wicket:id="text2"></span></a></td>
>     <td wicket:id="3"><a href="#" wicket:id="link3" target="_detail"><span
> wicket:id="text3"></span></a></td>
>     <td wicket:id="4"><a href="#" wicket:id="link4" target="_detail"><span
> wicket:id="text4"></span></a></td>
>     </tr>
> </table>
> </form>
>
> Then I process the above html code as a subclass of Link, process all
> onClick/onSubmit. And it would be fine if I just want to show info page on
> the List. If I set onClick to setResponsePage(new BookDetailPage(Book aBook,
> ...other Param));
>
> List.java
>
> void onClick()
> {
>     setResponsePage(new BookDetailPage(Book aBook, ...other Param));
> }
>
> Detail.html
> <form wicket:id="EditForm">
>     <span wicket:id="booksId"></span>
>     <input type="text" wicket:id="booksName"></input>
>     <input type="text" wicket:id="booksPublisher"></input>
>     <span wicket:id="booksUpdateTime"></span>
>     <p></p>
>     <input type="submit" wicket:id="btnCommit"></input>
> </form>
>
> But what I want is to show book info (BookDetailPage) on the detail page.
> so I use 3 iframes to include those 3 pages into one page - book_index, then
> process all iframe to wicket class InlineFrame.
> The reason of using iframe is to decrease the full-page reload and db
> connection that bookshelf uses.
>
> Book_Index.html
> <form>
> <iframe wicket:id="_iMenu" frameborder="1" framespacing="0" width="20%"
> height="100%" align="left"></iframe>
> <iframe wicket:id="_iList" frameborder="1" framespacing="0" width="80%"
> height="75%" align="top" scrolling="no"></iframe>
> <iframe wicket:id="_iDetail" name="_detail" frameborder="1"
> framespacing="0" width="80%" height="25%" align="buttom"></iframe>
> </form>
>
> Book_Index.java
>     Books_Index()
>     {
>         super();
>         add(new InlineFrame("_iMenu", new LeftMenu()));
>         FunctionPage master = new FunctionPage(this);
>
>         InlineFrame f_master = new InlineFrame("_iList",master);
>         add(f_master);
>
>         DataEditPage detail = new DataEditPage();
>         InlineFrame iDetail = new InlineFrame("_iDetail", detail);
>         iDetail.setOutputMarkupId(true);
>         add(iDetail);
>
>         master.setEditorPage(detail, this);
>     }
>
> I've tried to specified form post target, url target on the List.html but
> not works.
> Or use it on List
>
> ListPage
> void onClick()
> {
>     /* init actions */
>
>     /* target is still remain in self */
>      this.RequestCycle().setRequestTarget(new
> PageReferenceRequestTarget(detailPage));
>      this.setResponsePage(new DetailPage());
>
>     /*  no compatible RequestTarget for InlineFrame*/
>      this.RequestCycle().setRequestTarget(detailFrame);
>      this.setResponsePage(new DetailPage());
> }
>
>
> Is any way that can set link/post target to the detail frame, or other way
> I should do without iframe?
>
> Regards,
> Victor Chen
>