You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by mwrohde <mr...@navicure.com> on 2013/01/21 22:21:27 UTC

Re: [ANN] JumpStart gets jQuery DataTables example

Emmanuel DEMEY wrote
> . . . .
> But you can also use the ajax mode, and when the user will change the
> displayed page, send an ajax request, and update the datatable with the
> next set of datas.
> . . . .

I am having a devil of a time getting this to work.  I'm attaching probably
too much code here.  Please don't be overly critical.  I've borrowed this
from a demonstration that I found somewhere that is using celebrities as
sample data.  I'm trying to convert it to use server side pagination and
sorting, and my database connection pool.  There have been many iterations
of this trying to get various parts of it to work.  I can suss out
everything, if I can just get the ajax requests handled on the server side.

Right now, the only way I can see is to override the DataTableModel and call
it from an event handler.  But, that just seems wrong.  Anyway, here's the
mess I've made.  Can you help me clean it up?

DataTableDemo.tml:
<t:jquery.datatable id="dataTable" t:row="model" t:rowIndex="indexBis"
t:mode="true" t:source="celebrityService" t:dataTableModel="override"
                    rowsPerPage="5" exclude="id"
reorder="lastName,firstName,occupation,DOB" options="initParams">
</t:jquery.datatable>

DataTableDemo.java
public class DataTableDemo {
    @SessionState  // I think I have to do this so the data source service
can keep track of what's been requested
    private CelebrityService celebrityService;

    @Property
    @Environmental //This annotation is required for the property bound to
'index' parameter
    private int indexBis;
    
    @Property
    @Environmental
    private Celebrity model;

    @Property
    private Celebrity celebrity;
    
    @Inject
    private TranslatorSource translatorSource;
    
    @Inject
    private ComponentResources componentResources;
    
    @Inject 
    private PageRenderLinkSource linkSource;
    
    @Inject
    private BeanModelSource beanModelSource;
    
    @Property
    private final DataTableModel override = new
OverrideDataTableModel(translatorSource, componentResources, linkSource);
    
    // This is called by tapestry because in the tml file we have
't:source="celebritySource"'
    public GridDataSource getCelebrityService() {
        if (celebrityService == null)
            celebrityService = new CelebrityService();
        return celebrityService;
    }

    @Log
    public JSONObject getInitParams(){
        JSONObject initParams = new JSONObject();
        
        // This is the search bar.
        initParams.put("bFilter", false);
        
        // This says "displaying x of y pages"
        initParams.put("bInfo", true);
        
        // Make it pass all requests to the server??
        initParams.put("sAjaxSource",
componentResources.createEventLink("Data").toAbsoluteURI());
        initParams.put("bServerSide", "true");
        initParams.put("bProcessing", "true");
        
        // Trying to resize the table, but it doesn't work.  Last name
column is still huge with true or false
        initParams.put("fnInitComplete", "function() {
this.fnAdjustColumnSizing(false); }"); 

        return initParams;
    }
    
    @OnEvent(value=JQueryEventConstants.DATA)
    void hitThisMethod() {
        override.sendResponse(request, source, model, sortModel, overrides,
mode); // This isn't complete.  I'm quite stuck here.
    }
}

OverrideDataTableModel.java  // borrowed (completely?) from
DefaultDataTableModel
public class OverrideDataTableModel implements DataTableModel {
    Logger logger = Logger.getLogger(OverrideDataTableModel.class);

    private TranslatorSource translatorSource;

    private PageRenderLinkSource linkSource;

    private Request request;

    private GridSortModel sortModel;

    private PropertyOverrides overrides;

    private ComponentResources componentResources;

    private BeanModel model;

    public OverrideDataTableModel(TranslatorSource translatorSource,
ComponentResources componentResources,
            PageRenderLinkSource linkSource) {
        super();
        logger.trace("In constructor");
        this.translatorSource = translatorSource;
        this.linkSource = linkSource;
    }

    /**
     * This method will set all the Sorting stuffs, thanks to sSortDir and
     * iSortCol DataTable parameters, coming from the request
     */
    @Log
    public void prepareResponse(GridDataSource source) {
        logger.trace("prepareResponse()");
        String sortingCols =
request.getParameter(DataTableConstants.SORTING_COLS);
        int nbSortingCols = Integer.parseInt(sortingCols);
        logger.debug("sortingCols [" + sortingCols + "]");

        String sord = request.getParameter(DataTableConstants.SORT_DIR +
"0");
        String sidx = request.getParameter(DataTableConstants.SORT_COL +
"0");
        logger.debug("sord [" + sord + "]");
        logger.debug("sidx [" + sidx + "]");
        
        if (nbSortingCols > 0) {
            List<String> names = model.getPropertyNames();

            int indexProperty = Integer.parseInt(sidx);

            String propName = names.get(indexProperty);
            logger.debug("propName [" + propName + "]");

            ColumnSort colSort = sortModel.getColumnSort(propName);

            sortModel.updateSort(propName);
        }

    }

    /**
     * method returning the desired data
     */
    @Log
    public JSONObject getResponse(GridDataSource source) {
        logger.trace("getRespons()");
        JSONObject response = new JSONObject();
        int records = source.getAvailableRows();
        logger.debug("records [" + records + "]");

        response.put("sEcho",
request.getParameter(DataTableConstants.ECHO));
        response.put("iTotalDisplayRecords", records);
        response.put("iTotalRecords", records);

        String displayStart =
request.getParameter(DataTableConstants.DISPLAY_START);
        int startIndex = Integer.parseInt(displayStart);
        logger.debug("startIndex [" + startIndex + "]");

        String displayLength =
request.getParameter(DataTableConstants.DISPLAY_LENGTH);
        logger.debug("displayLength [" + displayLength + "]");

        int rowsPerPage = Integer.parseInt(displayLength);

        int endIndex = startIndex + rowsPerPage - 1;
        if (endIndex > records - 1)
            endIndex = records - 1;
        
        // Here we go - run the query
        source.prepare(startIndex, endIndex,
sortModel.getSortConstraints());

        JSONArray rows = new JSONArray();

        for (int index = startIndex; index <= endIndex; index++) {
            JSONObject cell = new JSONObject();

            Celebrity celebrity = (Celebrity) source.getRowValue(index);

            List<String> fields = model.getPropertyNames();
            logger.debug("fields [" + fields + "]");

            for (String fieldName : fields) {
                logger.debug("fieldName [" + fieldName + "]");
                
                Object fieldValue;
                
                PropertyConduit conduit = model.get(fieldName).getConduit();

                fieldValue = conduit.get(celebrity);
                logger.debug("fieldValue [" + fieldValue + "]");

                if (!String.class.equals(model.get(fieldName).getClass())
                        &&
!Number.class.isAssignableFrom(model.get(fieldName).getClass())) {
                    Translator translator =
translatorSource.findByType(model.get(fieldName).getPropertyType());
                    if (translator != null) {
                        fieldValue = translator.toClient(fieldValue);
                    } else {
                        fieldValue = fieldValue != null ?
fieldValue.toString() : "";
                    }
                }
                cell.put(fieldName, fieldValue);
            }

            rows.put(cell);
        }

        response.put("aaData", rows);

        logger.debug("rows [" + rows + "]");
        return response;
    }

    @Override
    public JSONObject sendResponse(Request request, GridDataSource source,
BeanModel model, GridSortModel sortModel,
            PropertyOverrides overrides, boolean mode) throws IOException {
        logger.trace("sendResponse()");
        this.request = request;
        this.sortModel = sortModel;
        this.model = model;
        this.overrides = overrides;

        GridDataSource gridDataSource = source;

        prepareResponse(gridDataSource);

        JSONObject response = getResponse(gridDataSource);
        logger.debug("response [" + response.toString() + "]");
        return response;
    }
}

CelebrityService.java
public class CelebrityService implements GridDataSource {
    private SqlSessionFactory sqlSessionFactory;
    private List<Celebrity> selection; // wtf
    private int startIndex; // wtf
    private List<Celebrity> celebrities = new ArrayList<Celebrity>(); // not
going to need this for long.  This is so getRange has something to do 
    
    public CelebrityService() {
        sqlSessionFactory =
MyBatisConnectionFactory.getSqlSessionFactory();;
    }

    // not going to need this for long.  THis is so getRange() has something
to do
    public void getAllCelebrities() {
        SqlSession session = sqlSessionFactory.openSession();
        try {
            CelebrityMapper mapper =
session.getMapper(CelebrityMapper.class);
            celebrities = mapper.selectAll();
        } finally {
            session.close();       
        }
    }

    @Override
    public int getAvailableRows() {
        SqlSession session = sqlSessionFactory.openSession();
        int count;
        try {
            CelebrityMapper mapper =
session.getMapper(CelebrityMapper.class);
            count = mapper.count();
        } finally {
            session.close();       
        }
        return count;
    }

    @Override
    public void prepare(int startIndex, int endIndex, List<SortConstraint>
sortConstraints) {
        // TODO Auto-generated method stub
        selection = getRange(startIndex, endIndex);
        this.startIndex = startIndex;
    }

    @Override
    public Object getRowValue(int index) {
        // TODO Auto-generated method stub
        if (selection == null) {
            prepare(0,14, new ArrayList());
        }
        return selection.get(index - this.startIndex);
    }

    @Override
    public Class<Celebrity> getRowType() {
        return Celebrity.class;
    }
    
    private List<Celebrity> getRange(int indexFrom, int indexTo) {
        // TODO This method needs to pay attention to indexFrom and indexTo
and only get x number of records per time
        List<Celebrity> result = new ArrayList<Celebrity>();
        if (celebrities == null || celebrities.isEmpty()) {
            getAllCelebrities();
        }
        for (int i = indexFrom; i <= indexTo; i++) {
            result.add(celebrities.get(i));
        }
        return result;
    }




--
View this message in context: http://tapestry.1045711.n5.nabble.com/ANN-JumpStart-gets-jQuery-DataTables-example-tp5715816p5719410.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [ANN] JumpStart gets jQuery DataTables example

Posted by Chris Poulsen <ma...@nesluop.dk>.
I know you can use them on the same field in pages/components, I was trying
to offer an alternate way of getting the instance of the service setup
correctly (by using IoC) instead of using a getter with side-effects as
suggested in an earlier post. ;)

-- 
Chris


On Wed, Jan 23, 2013 at 12:59 AM, Thiago H de Paula Figueiredo <
thiagohp@gmail.com> wrote:

> On Tue, 22 Jan 2013 20:43:15 -0200, Chris Poulsen <ma...@nesluop.dk>
> wrote:
>
>  One could also @Inject CelebrityService into a @Property i suppose?
>> (Using Tapestry IoC to manage the licecycle of the service).
>>
>
> Yep. You can use @Inject and @Propert in the same field just fine. Of
> course, @Property will only work in classes instantiated by Tapestry (the
> web framework, not Ioc): pages, components and mixins.
>
> --
> Thiago H. de Paula Figueiredo
>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.**apache.org<us...@tapestry.apache.org>
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: [ANN] JumpStart gets jQuery DataTables example

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Tue, 22 Jan 2013 20:43:15 -0200, Chris Poulsen <ma...@nesluop.dk>  
wrote:

> One could also @Inject CelebrityService into a @Property i suppose?  
> (Using Tapestry IoC to manage the licecycle of the service).

Yep. You can use @Inject and @Propert in the same field just fine. Of  
course, @Property will only work in classes instantiated by Tapestry (the  
web framework, not Ioc): pages, components and mixins.

-- 
Thiago H. de Paula Figueiredo

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [ANN] JumpStart gets jQuery DataTables example

Posted by Chris Poulsen <ma...@nesluop.dk>.
One could also @Inject CelebrityService into a @Property i suppose? (Using
Tapestry IoC to manage the licecycle of the service).

-- 
Chris


On Tue, Jan 22, 2013 at 10:14 PM, Geoff Callender <
geoff.callender.jumpstart@gmail.com> wrote:

> setupRender() doesn't get called in an AJAX request.
>
>
> http://jumpstart.doublenegative.com.au/jumpstart/examples/ajax/whatiscalledandwhen
>
> so celebrityService was null.  You can either:
>
> - @Persist it. That makes the page stateful, which is best avoided.
>
> - use Firebug or Web inspector to figure out what the event is that's
> being requested, then create a handler method for it and instantiate
> celebrity service in it.
>
> - remove @Property from celebrityService and try
>
>         @Cached
>         public CelebrityService getCelebrityService() {
>                 celebrityService = new CelebrityService();
>         }
>
> That's all can think of right now.
>
> Cheers,
>
> Geoff
>
> On 23/01/2013, at 7:32 AM, mwrohde wrote:
>
> > Ok, I got it working and my sanity is returning.  I'm not sure I've done
> it
> > the best way and I welcome any comments.
> >
> > My previous suppositions were on the right track.  Tapestry wasn't
> getting
> > the correct GridDataSource.  In fact, it wasn't finding one at all, so
> was
> > using NullGridDataSource.
> >
> > In the tml I have /t:source="celebrityService"/.  In the java I have
> private
> > /CelebrityService celebrityService;/
> >
> > I also have a setupRender method:
> > void setupRender() {
> >        if (celebrityService == null)
> >            celebrityService = new CelebrityService();
> >    }
> >
> > setupRender was being called.  However, it seems that tapestry was also
> > calling getCelebrityService, which I had no implemented.  So, I added a
> > getCelebrityService() method that does exactly what setupRender() does
> and
> > it started working.
> >
> >
> >
> > --
> > View this message in context:
> http://tapestry.1045711.n5.nabble.com/ANN-JumpStart-gets-jQuery-DataTables-example-tp5715816p5719427.html
> > Sent from the Tapestry - User mailing list archive at Nabble.com.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: [ANN] JumpStart gets jQuery DataTables example

Posted by mwrohde <mr...@navicure.com>.
It does call setupRender().  Only once, and only when the page with the data
table is displayed.  Let me know if you would like my code.



--
View this message in context: http://tapestry.1045711.n5.nabble.com/ANN-JumpStart-gets-jQuery-DataTables-example-tp5715816p5719498.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [ANN] JumpStart gets jQuery DataTables example

Posted by mwrohde <mr...@navicure.com>.
Now that I've written that I can't prove it.  I'm having some
buffering/timing issues in my log.  I'll do a little more analysis and let
you know.



--
View this message in context: http://tapestry.1045711.n5.nabble.com/ANN-JumpStart-gets-jQuery-DataTables-example-tp5715816p5719491.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [ANN] JumpStart gets jQuery DataTables example

Posted by mwrohde <mr...@navicure.com>.
I'll help you any way that I can.  I'll give you my code if you want.

I was just double checking to see what conditions called that method. 
Oddly, it's not when that page is rendered.

My app has a page with links to several other pages.  One of those links is
to the page with the jquery datatable.  When the page with the links is
rendered setupRender() is called on my data table page.  At no time during
display of the data table page itself is setupRender() called.



--
View this message in context: http://tapestry.1045711.n5.nabble.com/ANN-JumpStart-gets-jQuery-DataTables-example-tp5715816p5719490.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [ANN] JumpStart gets jQuery DataTables example

Posted by Geoff Callender <ge...@gmail.com>.
Hi Matt,

It is important that I keep the example that I sent you correct, ie. 

	http://jumpstart.doublenegative.com.au/jumpstart/examples/ajax/whatiscalledandwhen

so if you have found an AJAX situation that calls setupRender() then please let me know so that I can add it to the example. In theory, setupRender() should only be called during a page render request, as seen here:

	http://jumpstart.doublenegative.com.au/jumpstart/examples/navigation/whatiscalledandwhen

Regards,

Geoff

On 24/01/2013, at 12:38 AM, mwrohde wrote:

> Geoff Callender-2 wrote
>> setupRender() doesn't get called in an AJAX request.
> 
> I very much appreciate all the help (from everyone).  However, just for
> feedback, it is definately calling setupRender().  I've got logging
> statements in each method and that one is getting called.
> 
> I'm going to install Firebug and see what's what.
> 
> Thanks, again.
> 
> 
> 
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/ANN-JumpStart-gets-jQuery-DataTables-example-tp5715816p5719448.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 


Re: [ANN] JumpStart gets jQuery DataTables example

Posted by mwrohde <mr...@navicure.com>.
Geoff Callender-2 wrote
> setupRender() doesn't get called in an AJAX request.

I very much appreciate all the help (from everyone).  However, just for
feedback, it is definately calling setupRender().  I've got logging
statements in each method and that one is getting called.

I'm going to install Firebug and see what's what.

Thanks, again.



--
View this message in context: http://tapestry.1045711.n5.nabble.com/ANN-JumpStart-gets-jQuery-DataTables-example-tp5715816p5719448.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [ANN] JumpStart gets jQuery DataTables example

Posted by Geoff Callender <ge...@gmail.com>.
setupRender() doesn't get called in an AJAX request.

	http://jumpstart.doublenegative.com.au/jumpstart/examples/ajax/whatiscalledandwhen

so celebrityService was null.  You can either:

- @Persist it. That makes the page stateful, which is best avoided.

- use Firebug or Web inspector to figure out what the event is that's being requested, then create a handler method for it and instantiate celebrity service in it.

- remove @Property from celebrityService and try 

	@Cached
	public CelebrityService getCelebrityService() {
		celebrityService = new CelebrityService();
	}

That's all can think of right now.

Cheers,

Geoff

On 23/01/2013, at 7:32 AM, mwrohde wrote:

> Ok, I got it working and my sanity is returning.  I'm not sure I've done it
> the best way and I welcome any comments.
> 
> My previous suppositions were on the right track.  Tapestry wasn't getting
> the correct GridDataSource.  In fact, it wasn't finding one at all, so was
> using NullGridDataSource.
> 
> In the tml I have /t:source="celebrityService"/.  In the java I have private
> /CelebrityService celebrityService;/
> 
> I also have a setupRender method:
> void setupRender() {
>        if (celebrityService == null)
>            celebrityService = new CelebrityService();
>    }
> 
> setupRender was being called.  However, it seems that tapestry was also
> calling getCelebrityService, which I had no implemented.  So, I added a
> getCelebrityService() method that does exactly what setupRender() does and
> it started working.
> 
> 
> 
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/ANN-JumpStart-gets-jQuery-DataTables-example-tp5715816p5719427.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [ANN] JumpStart gets jQuery DataTables example

Posted by mwrohde <mr...@navicure.com>.
Ok, I got it working and my sanity is returning.  I'm not sure I've done it
the best way and I welcome any comments.

My previous suppositions were on the right track.  Tapestry wasn't getting
the correct GridDataSource.  In fact, it wasn't finding one at all, so was
using NullGridDataSource.

In the tml I have /t:source="celebrityService"/.  In the java I have private
/CelebrityService celebrityService;/

I also have a setupRender method:
void setupRender() {
        if (celebrityService == null)
            celebrityService = new CelebrityService();
    }

setupRender was being called.  However, it seems that tapestry was also
calling getCelebrityService, which I had no implemented.  So, I added a
getCelebrityService() method that does exactly what setupRender() does and
it started working.



--
View this message in context: http://tapestry.1045711.n5.nabble.com/ANN-JumpStart-gets-jQuery-DataTables-example-tp5715816p5719427.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [ANN] JumpStart gets jQuery DataTables example

Posted by mwrohde <mr...@navicure.com>.
It's not working at all and I'm getting close to running screaming from the
building.  Following is more code.  It is the current state of affairs. 
With the code as displayed I get this error:

> Failure reading parameter 'model' of component
> misc/DataTableDemo:datatable: Unable to determine the bean type for rows
> from org.apache.tapestry5.internal.grid.NullDataSource@187a72d9. You
> should bind the model parameter explicitly.

It looks to me like that is a result of it not knowing what class type to
use to display records.  I would have thought that /t:row="current"/ and
it's associated plumbing would have taken care of that.  Or, calling
/getRowType()/ method, which is returning a class, should solve that
problem.

Further, it looks like NullDataSource is used when it can't find my defined
datasource.  This also doesn't make sense to me as it is defined in the tml
and java.

If I add /t:model="model"/ and some java code associated with that to create
a BeanModel I don't get any errors, but /prepare()/ is not called an queries
are not run.

So, here's the code.  Thank you in advance for your help (and talking me
down from the ledge).

DataTableDemo.tml:
<t:jquery.datatable id="dataTable" t:row="current" t:mode="true"
t:source="celebrityService" 
                    rowsPerPage="5" exclude="id"
reorder="lastName,firstName,occupation,DOB" options="initParams">
</t:jquery.datatable>

DataTableDemo.java
public class DataTableDemo {
    @Property
    private CelebrityService celebrityService;

    @Property
    @Environmental
    private Celebrity current;

    public JSONObject getInitParams(){
        //snipped
    }
    
    void setupRender() {
        if (celebrityService == null)
            celebrityService = new CelebrityService();
    }
}

CelebrityService.java
public class CelebrityService implements GridDataSource {
    private SqlSessionFactory sqlSessionFactory;
    private List<Celebrity> preparedResults;
    private int startIndex;
    
    public CelebrityService() {
        sqlSessionFactory =
MyBatisConnectionFactory.getSqlSessionFactory();;
    }

    @Override
    public int getAvailableRows() {
        SqlSession session = sqlSessionFactory.openSession();
        int count;
        try {
            CelebrityMapper mapper =
session.getMapper(CelebrityMapper.class);
            count = mapper.count();
        } finally {
            session.close();       
        }
        return count;
    }

    @Override
    public void prepare(int startIndex, int endIndex, List<SortConstraint>
sortConstraints) {
        List<SortCriterion> sortCriteria = toSortCriteria(sortConstraints);
        this.startIndex = startIndex;
        
        SqlSession session = sqlSessionFactory.openSession();
        try {
            CelebrityMapper mapper =
session.getMapper(CelebrityMapper.class);
            preparedResults = mapper.selectAll();
        } finally {
            session.close();       
        }
    }

    private List<SortCriterion> toSortCriteria(List<SortConstraint>
sortConstraints) {
        System.out.println("CelebrityService toSortCriteria()");
        List<SortCriterion> sortCriteria = new ArrayList<SortCriterion>();

        for (SortConstraint sortConstraint : sortConstraints) {

            String propertyName =
sortConstraint.getPropertyModel().getPropertyName();
            SortDirection sortDirection = SortDirection.UNSORTED;

            switch (sortConstraint.getColumnSort()) {
            case ASCENDING:
                sortDirection = SortDirection.ASCENDING;
                break;
            case DESCENDING:
                sortDirection = SortDirection.DESCENDING;
                break;
            default:
            }

            SortCriterion sortCriterion = new SortCriterion(propertyName,
sortDirection);
            sortCriteria.add(sortCriterion);
        }

        return sortCriteria;
    }
    
    @Override
    public Object getRowValue(int index) {
        return preparedResults.get(index - startIndex);
    }

    @Override
    public Class<Celebrity> getRowType() {
        return Celebrity.class;
    }
}




--
View this message in context: http://tapestry.1045711.n5.nabble.com/ANN-JumpStart-gets-jQuery-DataTables-example-tp5715816p5719422.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [ANN] JumpStart gets jQuery DataTables example

Posted by mwrohde <mr...@navicure.com>.
Thank you for the reply.  I've looked at the first one extensively, and
stolen . . . . er, borrowed . . . . code from it.

I think the second one may be the magic I'm looking for, though.  I'll try
to implement something like it in my environment today.

Thanks again.  I'll let you know how it goes.



--
View this message in context: http://tapestry.1045711.n5.nabble.com/ANN-JumpStart-gets-jQuery-DataTables-example-tp5715816p5719416.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [ANN] JumpStart gets jQuery DataTables example

Posted by Nourredine <no...@atos.net>.
Hi, 

Just follow the sample described here :
http://tapestry5-jquery.com/components/docsdatatables (see snippets in
"Example with Ajax Mode" tab). 

You don't need to provide your own /datatableModel /nor the /hitThisMethod/
method

For the dataSource, you can take your inspiration from the jumpstart demo
site :
http://jumpstart.doublenegative.com.au/jumpstart/examples/tables/griddatasources
(the /prepare()/ method should process a database request).

Nourredine.



--
View this message in context: http://tapestry.1045711.n5.nabble.com/ANN-JumpStart-gets-jQuery-DataTables-example-tp5715816p5719414.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org