You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Márcio Gurgel <ma...@gmail.com> on 2008/04/04 01:46:03 UTC

Hi / Question - TabbedPanel with DisplayTag

Hi All!

This is my first e-mail.
My name is Márcio Gurgel, I'm from Brasília (Brazil). My english isn't very
well,  I hope you understand (:
There's 10 months that I'm working with J2EE.
I'll finish my graduation this semester, than I'm developing a final project
using Struts 2.

So, I have a question.. Hope you can help me.

My aplication uses displayTag for list rendering.
To make search's I use two tabs (Criteria and Results).
My problem is on the tab Results when it has paging.
When I click in the pagination, it just got lost.


I tried do resolve this doing:
1 - Seting requestURI="" to call the action that returns the jsp with my
tabbed panel.
This way, returns the tab of Criteria selected (I want the Results tab).
2 - Seting requestURI="" to call the action that returns the jsp with my
list (inside the Results tab).
This way my list opens in another frame.

Here's my code (I changed the Labels to english)
I atached a screen, as I sayd I dont trust in my english...


File UsuSeach.jsp (Contains tabbedPanel)
-----------------------------------------------------------------------------------------------------------------------

<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sx" uri="/struts-dojo-tags" %>
<%@ taglib prefix="d" uri="sgvdba-tags" %>

<script type="text/javascript">
   function selectTab(id) {
     var tabContainer = dojo.widget.byId("panelUsu");
     tabContainer.selectTab(id);
   }

</script>

<sx:head />

<d:titleBar title="User's search"/>

<s:url id="urlOpenCriteria" action="OpenCriteria" namespace="/user"/>
<s:url id="urlSearch" action="search" namespace="/user"/>

<sx:tabbedpanel id="panelUsu"  templateCssPath="/css/dojo/TabContainer.css">
    <sx:div label="Criteria" id="tabCriteria" href="%{urlOpenCriteria}"
loadingText="Carregando" />
    <sx:div label="Results" id="tabResults" href="%{urlSearch}"
loadingText="Carregando" refreshOnShow="false" preload="false"
executeScripts="true"/>
</sx:tabbedpanel>

File UsuSeachCriteria.jsp (Criteria)
-----------------------------------------------------------------------------------------------------------------------

<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sx" uri="/struts-dojo-tags" %>
<%@ taglib prefix="d" uri="sgvdba-tags" %>

<sx:head/>
<s:div cssClass="errors">
       <s:actionerror />
      <s:fielderror />
</s:div>

<s:form action="search" namespace="/user">
    <s:textfield name="currentUsu.chv" id="currentUsu.chv" label="User's
name" />
    <s:textfield name="currentUsu.eMail" id="usu.eMail" label="E-mail" />
    <sx:datetimepicker name="currentUsu.dtGvr" id="currentUsu.dtGvr"
label="Data gravação" toggleType="fade" toggleDuration="500"/>
    <d:buttonBar>
        <sx:submit id="buttonSearch" name="buttonSearch" value="Search"
onclick="selectTab('tabResults')" targets="tabResults" />
    </d:buttonBar>
</s:form>

File UsuSeachResults.jsp (Results)
-----------------------------------------------------------------------------------------------------------------------
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sx" uri="/struts-dojo-tags" %>
<%@ taglib prefix="d" uri="sgvdba-tags"%>
<%@ taglib prefix="display" uri="http://displaytag.sf.net"%>

<sx:head />

<br/>
<sx:div cssClass="errors">
       <s:actionerror />
      <s:fielderror />
</sx:div>

<s:form action="exclude" namespace="/user">
        <display:table sort="page"
requestURI="/usuario/abrirPesquisa.action" cellpadding="0"
cellspacing="0" id="listUsu"
        class="list" name="listUsuPesquisa" pagesize="10">
            <display:column    title='<input type="checkbox"
name="selectAll" id="selectAll" value="" onclick="checkAll()"/>'>
                <s:checkbox name="checkBox" id="checkBox" value="idUsus"
theme="simple" onclick="confirmAllChecked()" />
            </display:column>
            <display:column sortProperty="chv" title="User"
property="chv"/>//It's gonna be a link..
            <display:column title="E-mail" property="EMail"/>
            <display:column title="Date" property="dtGvr"/>
            <display:column title="Access level" property="nvlAcso.dcr" />
            <display:footer />
        </display:table>
    <br>
    <d:buttonBar>
        <sx:submit id="buttonNew" name="buttonNew" value="New" />
        <sx:submit id="buttonExclude" name="buttonExclude" value="Exclude"/>
    </d:buttonBar>
</s:form>



Tanks all!!!
[]'s

Re: Hi / Question - TabbedPanel with DisplayTag

Posted by Jeromy Evans <je...@blueskyminds.com.au>.
Hi Márcio,

First, check that the sort and pagination links rendered in the HTML 
appear valid.  I have seen cases where the URL is corrupt because it 
includes the original request parameters, resulting in the action being 
invoked with an unexpected result.

They should look like: 
http://foo.bar.com/context/requestUri?sort=name&dir=asc&originalParameters=originalValues.

The next issue is that displaytag uses default links that cause a 
complete page reload.  By "got lost", I presume you mean you clicked on 
the sort link and the resulting page did not show the current tag.  This 
is a complication of using complex widgets in html.  The only 
work-around with displaytag is to ensure all state about the page layout 
(such as which tab is visible) is available as a request param or read 
from a cookie on a reload so that when the page is redrawn with the 
correct tab and content displayed.

Finally, an approach to avoid that issue is use an ajax table widget. 
That is, one that can refresh it's data without performing a full page 
reload.  The AjaxTags library includes a direct implementation of the 
displaytag table (ajax:displaytag) [1]. I've never used it.  As you're 
using Dojo tabs you may like to consider Dojo's datagrid as well.  I use 
YUI's version.

[1] http://ajaxtags.sourceforge.net/usage.html

Hope that helps!

regards,
 Jeromy Evans

Márcio Gurgel wrote:
> Hi All!
>
> This is my first e-mail.
> My name is Márcio Gurgel, I'm from Brasília (Brazil). My english isn't very
> well,  I hope you understand (:
> There's 10 months that I'm working with J2EE.
> I'll finish my graduation this semester, than I'm developing a final project
> using Struts 2.
>
> So, I have a question.. Hope you can help me.
>
> My aplication uses displayTag for list rendering.
> To make search's I use two tabs (Criteria and Results).
> My problem is on the tab Results when it has paging.
> When I click in the pagination, it just got lost.
>
>
> I tried do resolve this doing:
> 1 - Seting requestURI="" to call the action that returns the jsp with my
> tabbed panel.
> This way, returns the tab of Criteria selected (I want the Results tab).
> 2 - Seting requestURI="" to call the action that returns the jsp with my
> list (inside the Results tab).
> This way my list opens in another frame.
>
> Here's my code (I changed the Labels to english)
> I atached a screen, as I sayd I dont trust in my english...
>
>
> File UsuSeach.jsp (Contains tabbedPanel)
> -----------------------------------------------------------------------------------------------------------------------
>
> <%@ taglib prefix="s" uri="/struts-tags" %>
> <%@ taglib prefix="sx" uri="/struts-dojo-tags" %>
> <%@ taglib prefix="d" uri="sgvdba-tags" %>
>
> <script type="text/javascript">
>    function selectTab(id) {
>      var tabContainer = dojo.widget.byId("panelUsu");
>      tabContainer.selectTab(id);
>    }
>
> </script>
>
> <sx:head />
>
> <d:titleBar title="User's search"/>
>
> <s:url id="urlOpenCriteria" action="OpenCriteria" namespace="/user"/>
> <s:url id="urlSearch" action="search" namespace="/user"/>
>
> <sx:tabbedpanel id="panelUsu"  templateCssPath="/css/dojo/TabContainer.css">
>     <sx:div label="Criteria" id="tabCriteria" href="%{urlOpenCriteria}"
> loadingText="Carregando" />
>     <sx:div label="Results" id="tabResults" href="%{urlSearch}"
> loadingText="Carregando" refreshOnShow="false" preload="false"
> executeScripts="true"/>
> </sx:tabbedpanel>
>
> File UsuSeachCriteria.jsp (Criteria)
> -----------------------------------------------------------------------------------------------------------------------
>
> <%@ taglib prefix="s" uri="/struts-tags" %>
> <%@ taglib prefix="sx" uri="/struts-dojo-tags" %>
> <%@ taglib prefix="d" uri="sgvdba-tags" %>
>
> <sx:head/>
> <s:div cssClass="errors">
>        <s:actionerror />
>       <s:fielderror />
> </s:div>
>
> <s:form action="search" namespace="/user">
>     <s:textfield name="currentUsu.chv" id="currentUsu.chv" label="User's
> name" />
>     <s:textfield name="currentUsu.eMail" id="usu.eMail" label="E-mail" />
>     <sx:datetimepicker name="currentUsu.dtGvr" id="currentUsu.dtGvr"
> label="Data gravação" toggleType="fade" toggleDuration="500"/>
>     <d:buttonBar>
>         <sx:submit id="buttonSearch" name="buttonSearch" value="Search"
> onclick="selectTab('tabResults')" targets="tabResults" />
>     </d:buttonBar>
> </s:form>
>
> File UsuSeachResults.jsp (Results)
> -----------------------------------------------------------------------------------------------------------------------
> <%@ taglib prefix="s" uri="/struts-tags"%>
> <%@ taglib prefix="sx" uri="/struts-dojo-tags" %>
> <%@ taglib prefix="d" uri="sgvdba-tags"%>
> <%@ taglib prefix="display" uri="http://displaytag.sf.net"%>
>
> <sx:head />
>
> <br/>
> <sx:div cssClass="errors">
>        <s:actionerror />
>       <s:fielderror />
> </sx:div>
>
> <s:form action="exclude" namespace="/user">
>         <display:table sort="page"
> requestURI="/usuario/abrirPesquisa.action" cellpadding="0"
> cellspacing="0" id="listUsu"
>         class="list" name="listUsuPesquisa" pagesize="10">
>             <display:column    title='<input type="checkbox"
> name="selectAll" id="selectAll" value="" onclick="checkAll()"/>'>
>                 <s:checkbox name="checkBox" id="checkBox" value="idUsus"
> theme="simple" onclick="confirmAllChecked()" />
>             </display:column>
>             <display:column sortProperty="chv" title="User"
> property="chv"/>//It's gonna be a link..
>             <display:column title="E-mail" property="EMail"/>
>             <display:column title="Date" property="dtGvr"/>
>             <display:column title="Access level" property="nvlAcso.dcr" />
>             <display:footer />
>         </display:table>
>     <br>
>     <d:buttonBar>
>         <sx:submit id="buttonNew" name="buttonNew" value="New" />
>         <sx:submit id="buttonExclude" name="buttonExclude" value="Exclude"/>
>     </d:buttonBar>
> </s:form>
>
>
>
> Tanks all!!!
> []'s
>
>   
> ------------------------------------------------------------------------
>
> No virus found in this incoming message.
> Checked by AVG. 
> Version: 7.5.519 / Virus Database: 269.22.5/1358 - Release Date: 3/04/2008 6:36 PM
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org