← Back to team overview

dhis2-devs team mailing list archive

Re: Translation function - Stay at page after modified some thing

 

On Mon, Mar 8, 2010 at 3:56 PM, Murodullo Latifov <murodlatifov@xxxxxxxxx>wrote:

> Hi Viet,
>
> Follow this steps to add pagination. I am listing those areas that
> added/modified for this, for the rest look at corresponding files attached.
> SearchText could be handled in a way during Add/Remove so user comes back to
> the last search criteria hi left. If this works than user will be always
> focused into set of data, rather going back to the whole set and researching
> again.
>
> Add these properties to GetDataElementListAction.java.
>
>     private String searchText ="";
>
>     public String getSearchText() {
>         return searchText;
>     }
>
>     public void setSearchText(String searchText) {
>         this.searchText = searchText;
>     }
>
>     private int pageSize = 10;
>
>     public int getPageSize() {
>         return pageSize;
>     }
>
>     public void setPageSize(int pageSize) {
>         this.pageSize = pageSize;
>     }
>
>     private int currentPage = 0;
>
>     public int getCurrentPage() {
>         return currentPage;
>     }
>
>     public void setCurrentPage(int currentPage) {
>         this.currentPage = currentPage;
>     }
>
> Change //dataElements = new ArrayList<DataElement>(
> dataElementService.getAllDataElements() ); to
>             dataElements = new ArrayList<DataElement>(
> dataElementService.getDataElements(currentPage, pageSize, searchText) );
>
> Create dataElementService.getDataElements(currentPage, pageSize,
> searchText)  as such:
>
>
>     // helper method for query based search, needed to add %% to search
> string and test if it is not null
>
>     private String getSearchPattern(String criteria) {
>     if (StringUtils.hasText(criteria)) {
>         return "%" + criteria.toLowerCase().replace('*', '%') + "%";
>     } else {
>         return "%%";
>         }
>     }
>
>     @SuppressWarnings("unchecked")
>     @Override
>     public Collection<DataElement> getDataElements(int currentPage,
>             int pageSize, String searchText) {
>         String pattern = getSearchPattern(searchText);
>         Session session = sessionFactory.getCurrentSession();
>
>         Criteria criteria = session.createCriteria( DataElement.class );
>         criteria.add(Restrictions.sqlRestriction("lower({alias}.name) like
> lower(?)", pattern, Hibernate.STRING)); //this is needed only if you want
> search functionality
>
>         return criteria.setMaxResults(pageSize).setFirstResult(currentPage
> * pageSize).list();
>     }
>
> Add these to dataelement.vm
> for search at the top:
>             #parse( "/dhis-web-maintenance-datadictionary/search.vm" )
> for pagination (prev/next) at the ned of table:
>
> <div class="nav">
>     #if($currentPage>0)
>     #set( $prevPage = $currentPage - 1 )
> <a id="prevResultsLink"
> href="dataElement.action?searchText=$searchText&pageSize=$pageSize&currentPage=$prevPage">$i18n.getString(
> "command.prev")</a>
> #end
> &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
> #if($count==$pageSize)
>     #set( $nextPage = $currentPage + 1 )
> <a id="prevResultsLink"
> href="dataElement.action?searchText=$searchText&pageSize=$pageSize&currentPage=$nextPage">$i18n.getString(
> "command.more")</a>
> #end
> </div>
>
>
>
>
Thank you very much Murodullo.

I will try to implement this to the patient list  and update to you soon.

Regards,

PS : Sorry Hieu, we are disturbing your thread ...next time update this
Paging things I will create new thread :-)


>
>
> ------------------------------
> *From:* Viet Nguyen <phamquocviet@xxxxxxxxx>
> *To:* Murodullo Latifov <murodlatifov@xxxxxxxxx>
> *Cc:* Hieu Dang Duy <hieu.hispvietnam@xxxxxxxxx>; Dhis2 <
> dhis2-devs@xxxxxxxxxxxxxxxxxxx>
> *Sent:* Mon, March 8, 2010 3:10:45 PM
> *Subject:* Re: [Dhis2-devs] Translation function - Stay at page after
> modified some thing
>
>
>
> On Mon, Mar 8, 2010 at 3:04 PM, Murodullo Latifov <murodlatifov@xxxxxxxxx>wrote:
>
>> Hi all,
>>
>> In this connection I also implemented server side pagination for dhis.
>> This could be used in Dataelement listing, patient records, etc. There is
>> also search facility working with pagination to narrow down scope. It may
>> need speed comparison with existing single listings and other pros and cons.
>>
>> regards,
>> murod
>>
>>
> Hi,
>
> I'm also planing to implement a paging util for patient module.
>
> May I see  your code  :-)
>
>


-- 
Viet Nguyen

References