0

Listbox Programmatically move to particular Page

asked 2015-01-30 22:24:59 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2623 3 8
http://emrpms.blogspot.in...

Hi

I am using the Listbox to show the records from the database as follows

    <div width="96%" sclass="sectionpadding">
                            <div sclass="floatright">
                                <paging id="pagenavi"
                                    pageSize="@load(vm.pageSize)" sclass="floatright"
                                    style="padding: 5px 84px 3px 12px;" pageIncrement="1"
                                    detailed="true" autohide="true">
                                </paging>
                            </div>
                            <div sclass="clearboth"></div>
                        </div>
                        <separator />


                        <listbox id="" mold="paging"
                            paginal="${pagenavi}" sclass="mylist"
                            selectedItem="@bind(vm.selectedItem)"
                            model="@load(vm.dataSet)">

And also, on double click of the listbox item , i am using some other page on the same container and in that page i have go back button to return to Listbox page.

Here user would like to show the same page no on clicking go back button. Here is the sample use case.

  1. A zul page xxxx.zul contains Listbox
  2. User Moves to 3 Page page.
  3. Double click any of the item to open yyyy.zul
  4. yyyy.zul opens in the same container.
  5. in yyyy.zul, we have go back button.
  6. On clicking go back button in yyyy.zul, we need to show the again xxxx.zul and also the listbox should point to 3 page.

So how we can move page in list box pro grammatically ?

delete flag offensive retag edit

Comments

Will work fine when you do on button click. Try to change when is page is load , as said , put the code in @afterCompose command in MVVM

Senthilchettyin ( 2015-02-01 01:38:07 +0800 )edit

Isn't the code now in aftercompose in the fiddle?

chillworld ( 2015-02-01 05:25:51 +0800 )edit

8 Answers

Sort by ยป oldest newest most voted
1

answered 2015-01-31 06:36:45 +0800

chillworld gravatar image chillworld flag of Belgium
5357 4 9
https://github.com/chillw...

updated 2015-02-05 08:58:05 +0800

Hey Senti.

Could this fiddle help you out?
As you can see I set the totalPages also to a calculated field.
Then the paging element will not go into error.

http://zkfiddle.org/sample/2j8njg9/1-setPaging-in-aftercompose

Edit :

Oke I see the problem. Try this :

this.pageSize = FHSessionUtil.getDesktopHeight() - 1;
activePage = this.searchClaim.getActivePage();
totalSize = (activePage + 1) * pageSize;
this.selectedClaim = null;
pageination.setTotalSize(totalSize);
pageination.setActivePage(activePage);
fetchRecord();
fetchTotals();

Edit2 :

Senti,

Now let us dig deeper. Copy the Page class and put it in your project (same FQN)
Class can be found here : https://github.com/zkoss/zk/blob/master/zul/src/org/zkoss/zul/Paging.java

Now, in the setActivePage put at the first line a logging for the totalsize.
I'm pretty sure the total size isn't what it should be but, beter to know what we get.

Greetz chill.

link publish delete flag offensive edit

Comments

So even in MVVM, we still need to use to component wire and set the active page properties. Please note in the above example,. pageination is wire component from zul ?

Senthilchettyin ( 2015-02-05 08:46:22 +0800 )edit

I still don't see a reason to mix MVVM and MVC here... am I missing something?

cor3000 ( 2015-02-12 04:14:15 +0800 )edit
1

answered 2015-02-12 06:49:42 +0800

cor3000 gravatar image cor3000
6280 2 7

updated 2015-02-12 06:50:17 +0800

@Senthil: It is very well possible and there is absolutely NO need to mix MVC/MVVM for this case (i.e. no need to @Wire any component).

Please see this running example showing a paging listbox with detail navigation (after double click) and a back button restoring the previous active page.

http://zkfiddle.org/sample/3g76ji5/1-MVVM-paging-list-detail-and-back-navigation

Robert

link publish delete flag offensive edit
0
link publish delete flag offensive edit

Comments

is there somewhere a fiddle?

chillworld ( 2015-01-31 08:36:49 +0800 )edit
0

answered 2015-02-05 05:22:40 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2623 3 8
http://emrpms.blogspot.in...

I am 200 % sure, it gives problem when we put the code at Aftercompose

I will try to give example .

link publish delete flag offensive edit
0

answered 2015-02-05 05:24:47 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2623 3 8
http://emrpms.blogspot.in...

Application Error Un Handled Application Error

More Error Information

500

org.zkoss.zk.ui.WrongValueException: Unable to set active page to 1 since only 1 pages at org.zkoss.zul.Paging.setActivePage(Paging.java:130) at com.product.webapp.billing.SearchClaimVM.onSearch(SearchClaimVM.java:410) at com.product.webapp.billing.SearchClaimVM.initSetup(SearchClaimVM.java:289) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.zkoss.bind.impl.ParamCall.call(ParamCall.java:113) at org.zkoss.bind.impl.AbstractAnnotatedMethodInvoker.invokeMethod(AbstractAnnotatedMethodInvoker.java:88) at org.zkoss.bind.BindComposer.doAfterCompose(BindComposer.java:173) at org.zkoss.zk.ui.impl.UiEngineImpl.doAfterCompose(UiEngineImpl.java:578) at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild0(UiEngineImpl.java:880) at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:826) at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:735) at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:797) at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:757) at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate(UiEngineImpl.java:699) at org.zkoss.zk.ui.impl.UiEngineImpl.createComponents(UiEngineImpl.java:1080) at org.zkoss.zk.ui.impl.AbstractExecution.createComponents0(AbstractExecution.java:251) at org.zkoss.zk.ui.impl.AbstractExecution.createComponents(AbstractExecution.java:243) at org.zkoss.zk.ui.Executions.createComponents(Executions.java:176) at com.product.webapp.billing.ClaimMainVM.onGoBack(ClaimMainVM.java:347) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.zkoss.bind.impl.ParamCall.call(ParamCall.java:113) at org.zkoss.bind.impl.BinderImpl.doExecute(BinderImpl.java:1748) at org.zkoss.bind.impl.BinderImpl.doCommand(BinderImpl.java:1509) at org.zkoss.bind.impl.BinderImpl.access$1500(BinderImpl.java:108) at org.zkoss.bind.impl.BinderImpl$CommandEventListener.onEvent0(BinderImpl.java:1378) at org.zkoss.bind.impl.BinderImpl$CommandEventListener.onEvent(BinderImpl.java:1330) at org.zkoss.zk.ui.AbstractComponent.onEvent(AbstractComponent.java:2746) at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:2717) at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:2658) at org.zkoss.zk.ui.impl.EventProcessor.process(EventProcessor.java:136) at org.zkoss.zk.ui.impl.UiEngineImpl.processEvent(UiEngineImpl.java:1765) at org.zkoss.zk.ui.impl.UiEngineImpl.process(UiEngineImpl.java:1550) at org.zkoss.zk.ui.impl.UiEngineImpl.execUpdate(UiEngineImpl.java:1260) at org.zkoss.zk.au.http.DHtmlUpdateServlet.process(DHtmlUpdateServlet.java:603) at org.zkoss.zk.au.http.DHtmlUpdateServlet.doGet(DHtmlUpdateServlet.java:485) at org.zkoss.zk.au.http.DHtmlUpdateServlet.doPost(DHtmlUpdateServlet.java:494) at javax.servlet.http.HttpServlet.service(HttpServlet.java:647) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:110) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:108) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:149) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:108) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)

link publish delete flag offensive edit

Comments

No for me it's no bug, your paging is still empty when you try to set the active page. Just one question, I don't know that use of paging (only use it with the totalsize, pagesize and activepage binded). How do you set the total elements of that paging component?

chillworld ( 2015-02-05 06:25:32 +0800 )edit

I'll explain the error. You set active page to 1 (what is page 2 in fact) and your total size is equal or below the pagesize, So ZK throws the error that you can't go to page 2 as there is only 1 page.

chillworld ( 2015-02-05 08:33:43 +0800 )edit
0

answered 2015-02-05 08:14:27 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2623 3 8
http://emrpms.blogspot.in...

Here is the Code

    Zul

<paging
pageSize="@bind(vm.pageSize)" id="pageination"
detailed="true" totalSize="@bind(vm.totalSize)"
activePage="@bind(vm.activePage)" />

View Model

@Wire("#pageination")
private Paging pageination;


this.pageSize = FHSessionUtil.getDesktopHeight() - 1;
activePage = this.searchClaim.getActivePage();
totalSize = (long) 0;
this.selectedClaim = null;
//The following line gives error message 
pageination.setActivePage(activePage);
fetchRecord();
fetchTotals();
link publish delete flag offensive edit
0

answered 2015-02-05 08:28:37 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2623 3 8
http://emrpms.blogspot.in...

updated 2015-02-05 08:29:23 +0800

Another example in different search page

     <paging
    id="pagenavi" pageSize="@load(vm.pageSize)"
    activePage="@bind(vm.activePage)"
    sclass="floatright" pageIncrement="1" detailed="true">
    </paging>

<listbox sclass="mylist"
                                                mold="paging" paginal="${pagenavi}" checkmark="true"
                                                onCheckSelectAll="@command('onSelectAll')" multiple="true"
                                                selectedItem="@bind(vm.selectedClaim)"
                                                selectedItems="@bind(vm.selectedClaims)"
                                                model="@load(vm.claimHeader)"
                                                emptyMessage="No record found for the given search condition.">

    @AfterCompose
        public void initSetup(@ContextParam(ContextType.VIEW) Component view,
                @ExecutionArgParam("container") Component container,
                @ExecutionArgParam("searchClaim") SearchClaim searchClaim,
                @ExecutionArgParam("MenuDetails") MenuItems menu) {
            Selectors.wireComponents(view, this, false);
            moreErrorInfo = this.getClass().getName();
            this.container = container;
            this.menu = menu;
            this.searchClaim = searchClaim;
            billingService = (BillingService) SpringUtil.getBean("BillingService");
            Borderlayout myborderLayout = (Borderlayout) view
                    .getFellow("searchclaimsmainlayout");
            myWest = myborderLayout.getWest();
            myWest.setOpen(false);
            prevBox = (Groupbox) view.getFellow("general");
            this.pageSize = FHSessionUtil.getDesktopHeight() - 1;
            zulpatientcode.setFocus(true);
            claimStatusList = billingService
                    .GetListByNamedQuery("ClaimStatus.getAllStatus");

            if (this.searchClaim == null) {
                initSearch();
            } else {
                this.claimHeader = searchClaim.getEdiClaims();
                this.searchTotals = searchClaim.getSearchTotals();
                this.searchClaim.setSearchWhere("SubmitElectronicClaims");
                this.searchClaim.setClaimTranModeType("EDI");
                this.totalSize = searchTotals.getTotalSize();
                // The following lines gives the error
                this.activePage = 4;
            }

        }
link publish delete flag offensive edit

Comments

you know pages are 0 based? (page 1 is activePage 0 )

chillworld ( 2015-02-05 08:31:19 +0800 )edit

there are totaly 50 pages. so that should not be the problem.

Senthilchettyin ( 2015-02-05 08:36:36 +0800 )edit

Even i set to 1 and gives me the error in the else section where i set this.activepage value

Senthilchettyin ( 2015-02-05 08:37:00 +0800 )edit

same error : Unable to set active page to 1 since only 1 pages at

chillworld ( 2015-02-05 08:41:16 +0800 )edit

yes. Same error

Senthilchettyin ( 2015-02-05 08:43:26 +0800 )edit
0

answered 2015-02-05 08:44:56 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2623 3 8
http://emrpms.blogspot.in...

http://screencast.com/t/eaH56lyjIY

link publish delete flag offensive edit

Comments

sorry no streaming media @work :(

chillworld ( 2015-02-05 08:47:25 +0800 )edit

My bad luck. I am trying both by wiring the component in VM and without wire and use activepage field, but no luck

Senthilchettyin ( 2015-02-05 08:51:56 +0800 )edit

I am tried, so i am going to say it is not possible :(

Senthilchettyin ( 2015-02-05 08:54:40 +0800 )edit

can you connect via teamviewer ?. give your email id ?

Senthilchettyin ( 2015-02-05 08:54:59 +0800 )edit

or you can send me test email at [email protected]

Senthilchettyin ( 2015-02-05 08:55:18 +0800 )edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2015-01-30 22:24:59 +0800

Seen: 77 times

Last updated: Feb 12 '15

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More