Entries Tagged as 'Tips & Tricks'

ColdFusion ORM - filtered has[property] gotcha...

Community , Walkthroughs , Alliance , Tutorials , Tips & Tricks 4 Comments »

I was working more with Coldfusion 9 ORM and found another small caveat I thought I would share.  When working with a relationship that is filtered, the implicit "has[property]", the has does not take into account the filter.  The implicit get works as expected however.  Consider the following persistent cfc...

Read more...

jQuery tabs and IE caching...

Community , Alliance , Tutorials , Tips & Tricks No Comments »

I ran into an interesting issue using the jQuery UI tabs ajax style and Internet Explorer. 

If you setup the tabs with the with the cache turned off, they will still be cached in IE.   I had worked around this issue by adding a counter that changed every time to my href for the tab, but I found a more elegant solution and thought I would share.

Read more...

Using the ColdBox Paging Carrousel Plugin

Plugins , ForgeBox , Tutorials , Tips & Tricks 2 Comments »


Let's learn how to use the paging carrousel plugin for ColdBox found in the ForgeBox directory.  First of all, download the plugin and drop in your custom plugins folder.


Settings setup

Make sure that you setup the following settings in your application:

PagingMaxRows - The maximum number of rows to show per page. Defaults to 10
PagingBandGap - The gap to use in the paging carrousel. Defaults to 5

You can also override the settings on the plugin, by using the appropriate setter methods in the plugin.

Handler setup

In your handler event, my case 'forgeservice.entries' you will setup the paging boundaries and the data call using these boundaries.  In my case, I have a model object that received the starting row and the maximum number of rows to return.  The paging plugin assumes there will be an incoming request collection variables called "page".  You do not need to param it or default it as the plugin does this for you.  All you have to do is construct a nice link with a page holder once you render the paging carrousel.  So to start just get the boundaries from the plugin:

// Get the paging boundaries, make sure there will be a "page" incoming variable, we use it to page.
rc.pageBoundaries = getMyPlugin("Paging").getBoundaries();

The previous call returns a structure with a startRow and maxRow element according to your settings and the page your are on.  You can use this information to present information back to the user like, showing records X to Y, etc.

// Call your model object for data
rc.entries = forgeService.getEntries(orderBy=rc.orderBy,
                                                            typeSlug=rc.typeSlug,
                                                            startrow=rc.pageBoundaries.startRow,
                                                            maxrows=getMyPlugin("Paging").getPagingMaxRows());     
      

The next tricky part is to get the total count with no paging on it.  I have another method that does this for me, but this can be done in any approach you prefer.

// Get total entries count
rc.entriesTotal = forgeService.getEntriesTotal(typeSlug=rc.typeSlug);

View Setup
That's it for the handler code, now let's render the paging carrousel.  For this make sure you have the correct css setup for it.  The following are what is needed for the paging css:

.pagingTabs - The div container
.pagingTabsTotals - The totals
.pagingTabsCarrousel - The carrousel

Here is my sample css: /* Paging */
.pagingTabs{
font-size: .8em;
text-align: left;
margin: 20px 10px 15px 10px;
}
.pagingTabs a{
color: #000;
padding: 2px 4px;
background-color: #fff;
border: 1px solid #ccc;
margin-left: 2px;
}
.pagingTabs a:hover{
color: #000;
background-color: #FCF9C3;
border: 1px solid black;
}
.pagingTabs a.selected{
color: #000;
background-color: #FCF9C3;
border: 1px solid #AF3D15;
}
.pagingTabsCarrousel{
margin-top:5px;
}


Now I can render it in my views:


#getMyPlugin("paging").renderit(foundRows=rc.entriesTotal,link=event.buildLink('forgebox/page/@page@')#


That's it! I tell the paging plugin what is the link to attach to my carrousel and then pass a placeholder variable for my page: @page@.  This renders the carrousel and correct links.


Some ColdFusion Development Best Practices

Community , Tutorials , Tips & Tricks 5 Comments »

We always are trying to help the ColdFusion community as much as we can.  We had a CFC best practices document in our ColdBox documentation site in order to steer developers in the right direction when building components.  I have updated the document to now include more topics than just CFCs.  So if you are interested in collaborating to this document or think some points are useless, please comment and we can make this document better.

So here are our ColdFusion Development Best Practices document: http://ortus.svnrepository.com/coldbox/trac.cgi/wiki/cbDevelopmentBestPractices

Coldbox SimpleMVC Demystifyed

Walkthroughs , News , Tips & Tricks 8 Comments »

I have been asked quite a few times why not make a ColdBox lite version where you can only have the basics?  Well, not many people now that this already exists.  Therefore, I am linking to the SimpleMVC template you can use if you are just starting with ColdBox.  This template is just the basic ColdBox conventions and a few settings, that's it. This template will ease you in to ColdBox MVC development.  Once you are comfortable with just the basics of how to build apps with conventions you can always add on and start brining in extra features from the Coldbox Platform like: caching, logging, AOP, interceptors, feed integrations, security, etc.  However, you won't feel as intimidated as if you where starting with a huge settings file.

The reason of having all the settings listed out is to tell the developer that there are all these settings you can use.  It is also hard to create templates when everybody's level and approach is different.  However, this can be overwhelming to entry level users, therefore we are now including the SimpleMVC template in the coldbox downloads to come or you can download it from here now: http://www.coldbox.org/downloads/simpleMVC.zip (3.0 template)

So let's do a simple ColdBox for Newbies guide:

Read more...