pagination in playframework - pagination

I want to implement pagination in Play FrameWork , Is there any tutorial or example for this
I have explore there website and went through the tutorial but not able to implement pagination
Thanks

I have implemented many pages in play! using the Play pagination module. It's working fine with no issues. I'll give you an idea of what I did, below.
First I declare the ValuePaginator that points to a result set (in my case a MYSQL query)
ValuePaginator vpaginator=query.resultList();
Then render the Paginator instance to use it in the view
render(vpaginator);
In the view, I used the following syntax
#{paginate.list items:paginator, as:'r'}
<table>
<tr>
<td>${r[0]}</td>
<td>${r[1]}</td>
<td>${r[2]}</td>
</tr>
</table>
#{/paginate.list}
Suppose my SQL query looks like this
Select name,id,address from table
then in that case r[0] will take the value of names, r[1] will take the value of id's and r[2] will take the value of addresses and render this data in 3 different columns in a table.
Hope this helps.

First solution is to use the paginate-module. Furthermore there was a discussion of different implementations to solve it at google-group one result of it can find at the snippet-page.
I hope that one of the solution fits to you.

Related

Xpage dynamic Id for data update or validation(CSJS)

Before describing the problem, I would like to add that I have looked for this problem on google and have found many solutions but none related to XPAGES. Since, Xpage have a unique method to generate the field id I am facing this problem. I have also posted the same question here on IBM forum and awaiting the reply there(http://www-10.lotus.com/ldd/ndseforum.nsf/xpTopicThread.xsp?documentId=EDEBB14BDF2E804F85257BE8001E4F76):
Problem:
I am trying to pass dynamic id to the default function getElementById with no success. To explain it clearly, I have a front end validation for specific fields. This fields are stored n database. So, I have a for loop running for all the fields. The problem here is that XPages generates the Id dynamically and hence for the same form if there is a hierarchical tabbed panel then the Id also included the tabbed panel Id in it.
Here is the code view of the problem:
The standard method to retrieve the value(CSJS) is:
document.getElementById("#{id:inputText1}").value;
However, if I try to pass in a dynamic id. It doesn't work. I have tried "n" number of approaches I found on Google but none regarding this problem. One solution I tried here was:
var x = "inputText1";
document.getElementById("#{id:"+x+"}").value;
Any help would really be appreciated. Really eager to hear some good suggestion.
The "#{id:inputText1}" part is computed at the server before the page is served so it's too late to set the ID in client side JS.
To set the ID in SSJS you can do this:
document.getElementById("#{javascript:var x='inputText1'; getClientId(x)}").value;
With getClientId you can also build a CSJS array of IDs in in SSJS. Then you can loop that array in CSJS. You would build the array this way:
var strIDs = ${javascript:'["a","b","c"]'};

Need to combine .getElementsByClass and .getElementsById to scrape data from website

I am writing a simple crawler using VBA. I found out that the data I am looking for correspond to the node <h6 class="country-name" id="Australia">.
I know that if I wanted to select data from, let us say, <div class="section-country">, I should use .getElementsByClassName("section-country") in my VBA macro.
In presence of both class and id in the node, which command should I insert in my VBA macro to scrape data?
Thanks a lot,
Avitus
EDIT: writing .getElementsByClassName("country-name").getElementsById("Australia") gives me an error. Why?
getElementsByID (plural) doesn't exist - there should only be one item with a given ID. Therefore, use getElementByID (singular) which does exist. If there happen to be multiple elements with the same ID, this function will return the first one.
As others have said, selecting by ID sounds more appropriate to what you want to do than selecting by class
There must be a method like getelementbyxpath you can use this method by using this xpath "//div[#class='country-name' and #id ='Australia']"
eg: getElementsByXpath("//div[#class='country-name' and #id ='Australia']")
Read More here how to set up a crawler for web scraping

Can you use dynamic finders or grouping tables via scaffold in Grails?

I'm working on a very, very quick and dirty application using almost entirely scaffold to do it. This is only for internal use, and it's just to replace a spreadsheet, so while I know that I shouldn't rely on scaffolds for real production use, I still intend to use them where I can for efficiency (...just wanted to make sure we aren't taken off track by the inevitable question!).
What I am curious about is since scaffolds can do quick and dirty CRUD, and you can do dynamic finders for searches, is there a way to dynamically show the "list" action of the scaffold with a constraint (i.e. show all items in the list that were created by this "user")? That would be fine for me...
Alternatively, is there anything available in Grails to allow "grouped" tables. Essentially the "list" action from the scaffold, but grouped by a particular attribute (again, think of grouping all the items by the user that created them).
Any help would be appreciated - I've scoured Google and some books with no luck, but wanted to check with the StackOverflow community before I dismiss the notion and write it by hand. Thanks!
We did the same in our Grails application and it's relatively easy:
Create a new form in the list.gsp referring to the list action <g:form action="list" method="post">
Inside that form, declare a table with the fields you want to search on:
<div class="buttons">
<span class="button"><g:submitButton name="list" class="search" value=" ${message(code: 'default.button.search.label', default: 'Search')}"/></span>
</div>
In the list action, build up the query (using findAll, findWhere, .. whatever takes your fancy) and return that to the page:
[wardInstanceList : Ward.findAll(whereClause, [max: params.max, offset: params.offset]) , wardInstanceTotal : (int) Ward.executeQuery("select count(*) " + whereClause).get(0)]
The whereClause looks something like: "from Ward where ward = 'something' and room = 'something else'"

subsonic . navigate among records ,view,query

i'm some newbie in this matter of .net
i'm trying understand this new paradigm
i began with linq for SQl
but i found this library, kind of framework of T4
more specifically: subsonic T4
i think it could be very usefull
but the support docs outside are very scarce
my first intention is use them in the very simple form: a catalog
lets say... Users
so...
how can i use the model generated with subsonic
( using the iactiverecord)
to implement the record-navigational part.,...???!!!
i mean
i want a simple form
to create, delete or modify records
and that is fairy easy
but
what about to move among records ?
i found how to get the first, the last record..
but how can i advance or go back among them???
how can i order the records..?
it seems everytime imust query the table..
its so?
but how can imove among the records i already got?
all of the exmples found are very simple
dont touch the matter and/ or are repetitive everywhere
so.. please
if anybody can help me
or give more references...
i'd thank you a lot
gmo camilo
SubSonic can return a List of your objects if you call ExecuteTypedList or ToList on a query e.g.
List<Product> products = Products.All().ToList();
Once you've got a List then you can move around it in memory. Have a look at the following references to learn more about collections in .net:
System.Collections.Generic Namespace
IEnumerable<(Of <(T>)>) Interface
List<(Of <(T>)>) Class

how do I implement a kohana pagination in MVC?

that's it. How do I implement the Kohana pagination library in MVC way? which code should go to the model? to the controller? to the view? I have seen tons of examples but none of them are implemented in MVC.
Pagination has two parts: the records filter part which should go in the controller and the display part which goes into the view. The example in the pagination library help is correct.
If you want to implement your own pagination library take a look here.
To fulfill the MVC philosophy, you could:
1) have 2 methods in a model which make the same query but one returns only the row count and the other returns the actual result, being able to apply a LIMIT and an OFFSET.
Let's say, Some_Model::get_results() and Some_Model::get_result_count()
2) In your controller, when pagination is needed, you call Some_Model::get_result_count() to know the total quantity of rows, and pass that value to Kohana's pagination initialization, to get the pages links, which you put into a variable to pass to the view.
3) In the view, you echo the variable that has the pages links, and voila!
Of course this assumes you read the Kohana documentation for pagination and its examples.
Hope it helps.

Resources