Primefaces p:datatable - Change {CurrentPageReport}

I`m searching and searching but I can not find anything to solve my problem. I use a DataTable (Primefaces) and wondered how I can change the language/output of some fields.

More precisely, I want to change the {CurrentPageReport} in PaginatorTemplate. Now, it looks very simple: (0 of 100). I want to have it like this (Page 0 of 100, 500 results).

I tried a lot, but nothing works. The last I did was:

function change_text () {
    $(".ui-paginator-current").each (function() {
        $(this).html("Simple test");
    });     
}

$(".ui-icon").each(
            function(index) {
                $( this ).bind ("click",function(){ change_text (); });
            }
    );

(ui-icon is part of each button in the table.)

But this is not really effective as you can see :-) This solution works half-way. When I press on a button (next page, previous page) the text in .ui-paginator-current field changes back to the default template. I know.. the reason is because this field is also being reloaded.

I also tried to change Primefaces Code but I can`t find the correct code area.

I am working with JSF 2.0.3 and PrimeFaces 2.2.1. How can I solve my problem? Can I load paginatorTemplate from a bean? It would really help me if I could change the text from "0 of 100" to "0 aus 100" (german).

Hope you guys can help me, like every time I have a problem.

Ioannis K.

Answers


Found it:

<p:dataTable currentPageReportTemplate="{currentPage} #{loc.of} {totalPages}" /> 

for those who are interested in it :-)

*Now: I have it like this:

paginatorTemplate="{FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"

currentPageReportTemplate="(Entries: {startRecord} - {endRecord} of {totalRecords}, Page: {currentPage}/{totalPages})"

Hope this helps you guys!


I haven't tested it but PrimeFaces does support German locale. Have you tried setting the locale in your bean to see if "0 of 100" changes to "0 aus 100" ?

FacesContext.getCurrentInstance().getViewRoot().setLocale(new Locale("de"));

Need Your Help

How can I use JavaScript to transform XML & XSLT?

javascript xml internet-explorer browser xslt

I want to use JavaScript to show my XSLT, but on my server nothing is showing up in the browser.

How to do attr_accessor_with_default in ruby?

ruby ruby-on-rails-3

Some code that I had that used attr_accessor_with_default in a rails model is now giving me a deprecation warning, telling me to "Use Ruby instead!"