|
I'm interested in adding some basic filtering to the default Grails
controller and list view generator and I want to solicit feedback before starting. First, look at the attached HTML file for an example of what the generated list.gsp could look like when "filterable" is included on one or more domain constraints. Basically, it just involves adding an extra row at the top of the table that would look something like this: <tr> <g:form controller="issue" method="post"> <th>max:<input type="text" size="1" name='max' value='${params.max}'/></th> <th><g:select name='type' from='${[""] + issue.constraints.type.inList}' value='${params.type}'></g:select></th> <th><input type="text" maxlength='30' name='title' value='${params.title}'></input></th> <th><g:select name='assignedTo' from='${[""] + issue.constraints.assignedTo.inList}' value='${params.assignedTo}'></g:select></th> <th></th> <th></th> <th class="actionButtons"><g:actionSubmit value="Filter" /></th> </g:form> </tr> and there would be a filter closure on the Controller that might look like this: def filter = { def c = Issue.createCriteria() def issueList = c.list() { if (params.type) { eq("type", params.type) } if (params.title) { // * is a wild-card for string filters def temp_title = params.title.replaceAll('\\*','%') if (temp_title.contains('%')) { ilike("title", temp_title) } else { eq("title", temp_title) } } if (params.assignedTo) { eq("assignedTo", params.assignedTo) } if (params.max) { maxResults(Integer.valueOf(params.max)) } } render(view:'list', model:[issueList:issueList, issue:new Issue()]) } ______________________________________________________________________ This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. Katun Corporation -- www.katun.com _____________________________________________________________________ --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email |
|
Hi Jonathan,
I starred this to follow up and have finally got round to it. I like the idea of filtering and think it would be a valuable addition (along with adding searching to scaffolded apps). The examples you have given seem a little robust, however. They seem to contain code specific to issue tracking systems, I imagine this could be made a lot simpler no? Cheers Graeme On 8/8/06, Jonathan Carlson <[hidden email]> wrote: > I'm interested in adding some basic filtering to the default Grails > controller and list view generator and I want to solicit feedback before > starting. First, look at the attached HTML file for an example of what > the generated list.gsp could look like when "filterable" is included on > one or more domain constraints. > > Basically, it just involves adding an extra row at the top of the table > that would look something like this: > > <tr> > <g:form controller="issue" method="post"> > <th>max:<input type="text" size="1" name='max' > value='${params.max}'/></th> > <th><g:select name='type' from='${[""] + > issue.constraints.type.inList}' value='${params.type}'></g:select></th> > > <th><input type="text" maxlength='30' name='title' > value='${params.title}'></input></th> > <th><g:select name='assignedTo' from='${[""] + > issue.constraints.assignedTo.inList}' > value='${params.assignedTo}'></g:select></th> > <th></th> > <th></th> > <th class="actionButtons"><g:actionSubmit value="Filter" /></th> > </g:form> > </tr> > > and there would be a filter closure on the Controller that might look > like this: > > def filter = { > def c = Issue.createCriteria() > def issueList = c.list() { > if (params.type) { > eq("type", params.type) > } > if (params.title) { // * is a wild-card for string filters > def temp_title = params.title.replaceAll('\\*','%') > if (temp_title.contains('%')) { > ilike("title", temp_title) > } else { > eq("title", temp_title) > } > } > if (params.assignedTo) { > eq("assignedTo", params.assignedTo) > } > if (params.max) { > maxResults(Integer.valueOf(params.max)) > } > } > render(view:'list', model:[issueList:issueList, issue:new > Issue()]) > } > > > ______________________________________________________________________ > This email and any files transmitted with it are confidential and > intended solely for the use of the individual or entity to whom they > are addressed. If you have received this email in error please notify > the system manager. > > Katun Corporation -- www.katun.com > _____________________________________________________________________ > > --------------------------------------------------------------------- > To unsubscribe from this list please visit: > > http://xircles.codehaus.org/manage_email > > > --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email |
|
In reply to this post by Jonathan Carlson
Graeme wrote:
> They seem to contain code specific to issue tracking systems, I imagine this > could be made a lot simpler no? Yes, it was just an example to give you an idea of what the basic generated code might look like, although the line-wrapping makes it look pretty ugly. I've modified the controller generating code, and it seems to generate the controller fine, but the actual generating code is more complex than I was hoping it would be. The current code generating class is OK for basic scaffolding, but it pretty much rules out any private customizations unless you don't mind forking away from the main code-base. I've also been a little uncomfortable with having UI definition stuff in the domain objects. Validation stuff belongs there, but not stuff like widget definitions, filterable, etc. It doesn't feel right to me, although if it is kept very minimal it can work OK. I've been thinking about a separate template directory that could have template files for the controller and view. This would allow optional project-specific customizations. Of course, you'd have to allow the Grails user to define what objects go into the template context as well. The Grails web site at one time bragged about not using templates and I never quite understood why that was such a good thing. The templates are there, they are just hidden inside of a class and thus aren't in a convenient place to modify. I still think the basic scaffolding could use some filtering out-of-the-box as I've suggested, though, if only as starter code. I could send you what I have for the basic controller generating and you could see if it surpasses the desired complexity threshold or not. Thanks, - Jonathan >>> [hidden email] 2006-08-16 3:17:57 PM >>> Hi Jonathan, I starred this to follow up and have finally got round to it. I like the idea of filtering and think it would be a valuable addition (along with adding searching to scaffolded apps). The examples you have given seem a little robust, however. They seem to contain code specific to issue tracking systems, I imagine this could be made a lot simpler no? Cheers Graeme On 8/8/06, Jonathan Carlson <[hidden email]> wrote: > I'm interested in adding some basic filtering to the default Grails > controller and list view generator and I want to solicit feedback before > starting. First, look at the attached HTML file for an example of what > the generated list.gsp could look like when "filterable" is included on > one or more domain constraints. > > Basically, it just involves adding an extra row at the top of the table > that would look something like this: > > <tr> > <g:form controller="issue" method="post"> > <th>max:<input type="text" size="1" name='max' > value='${params.max}'/></th> > <th><g:select name='type' from='${[""] + > issue.constraints.type.inList}' value='${params.type}'></g:select></th> > > <th><input type="text" maxlength='30' name='title' > value='${params.title}'></input></th> > <th><g:select name='assignedTo' from='${[""] + > issue.constraints.assignedTo.inList}' > value='${params.assignedTo}'></g:select></th> > <th></th> > <th></th> > <th class="actionButtons"><g:actionSubmit value="Filter" /></th> > </g:form> > </tr> > > and there would be a filter closure on the Controller that might > like this: > > def filter = { > def c = Issue.createCriteria() > def issueList = c.list() { > if (params.type) { > eq("type", params.type) > } > if (params.title) { // * is a wild-card for string filters > def temp_title = params.title.replaceAll('\\*','%') > if (temp_title.contains('%')) { > ilike("title", temp_title) > } else { > eq("title", temp_title) > } > } > if (params.assignedTo) { > eq("assignedTo", params.assignedTo) > } > if (params.max) { > maxResults(Integer.valueOf(params.max)) > } > } > render(view:'list', model:[issueList:issueList, issue:new > Issue()]) > } > > > > This email and any files transmitted with it are confidential and > intended solely for the use of the individual or entity to whom they > are addressed. If you have received this email in error please notify > the system manager. > > Katun Corporation -- www.katun.com > _____________________________________________________________________ > > --------------------------------------------------------------------- > To unsubscribe from this list please visit: > > http://xircles.codehaus.org/manage_email > > > --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________ ______________________________________________________________________ This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. Katun Corporation -- www.katun.com _____________________________________________________________________ --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email |
|
On 8/16/06, Jonathan Carlson <[hidden email]> wrote:
> Graeme wrote: > > They seem to contain code specific to issue tracking systems, I > imagine this > > could be made a lot simpler no? > > Yes, it was just an example to give you an idea of what the basic > generated code might look like, although the line-wrapping makes it look > pretty ugly. I've modified the controller generating code, and it seems > to generate the controller fine, but the actual generating code is more > complex than I was hoping it would be. > > The current code generating class is OK for basic scaffolding, but it > pretty much rules out any private customizations unless you don't mind > forking away from the main code-base. I've also been a little > uncomfortable with having UI definition stuff in the domain objects. > Validation stuff belongs there, but not stuff like widget definitions, > filterable, etc. It doesn't feel right to me, although if it is kept > very minimal it can work OK. > > I've been thinking about a separate template directory that could have > template files for the controller and view. This would allow optional > project-specific customizations. Of course, you'd have to allow the > Grails user to define what objects go into the template context as well. > > > The Grails web site at one time bragged about not using templates and I > never quite understood why that was such a good thing. The templates > are there, they are just hidden inside of a class and thus aren't in a > convenient place to modify. Well dynamic scaffolding (when you set scaffold=true) doesn't use templates to produce the controller code. The only templates used with that is for the views. > > I still think the basic scaffolding could use some filtering > out-of-the-box as I've suggested, though, if only as starter code. I > could send you what I have for the basic controller generating and you > could see if it surpasses the desired complexity threshold or not. Agreed. I think something that is simple to expand on and just does the basics of filtering would be a good addition Cheers Graeme > > Thanks, > > - Jonathan > > > >>> [hidden email] 2006-08-16 3:17:57 PM >>> > Hi Jonathan, > > I starred this to follow up and have finally got round to it. I like > the idea of filtering and think it would be a valuable addition (along > with adding searching to scaffolded apps). > > The examples you have given seem a little robust, however. They seem > to contain code specific to issue tracking systems, I imagine this > could be made a lot simpler no? > > Cheers > Graeme > > On 8/8/06, Jonathan Carlson <[hidden email]> wrote: > > I'm interested in adding some basic filtering to the default Grails > > controller and list view generator and I want to solicit feedback > before > > starting. First, look at the attached HTML file for an example of > what > > the generated list.gsp could look like when "filterable" is included > on > > one or more domain constraints. > > > > Basically, it just involves adding an extra row at the top of the > table > > that would look something like this: > > > > <tr> > > <g:form controller="issue" method="post"> > > <th>max:<input type="text" size="1" name='max' > > value='${params.max}'/></th> > > <th><g:select name='type' from='${[""] + > > issue.constraints.type.inList}' > value='${params.type}'></g:select></th> > > > > <th><input type="text" maxlength='30' name='title' > > value='${params.title}'></input></th> > > <th><g:select name='assignedTo' from='${[""] + > > issue.constraints.assignedTo.inList}' > > value='${params.assignedTo}'></g:select></th> > > <th></th> > > <th></th> > > <th class="actionButtons"><g:actionSubmit value="Filter" /></th> > > </g:form> > > </tr> > > > > and there would be a filter closure on the Controller that might > look > > like this: > > > > def filter = { > > def c = Issue.createCriteria() > > def issueList = c.list() { > > if (params.type) { > > eq("type", params.type) > > } > > if (params.title) { // * is a wild-card for string filters > > def temp_title = params.title.replaceAll('\\*','%') > > if (temp_title.contains('%')) { > > ilike("title", temp_title) > > } else { > > eq("title", temp_title) > > } > > } > > if (params.assignedTo) { > > eq("assignedTo", params.assignedTo) > > } > > if (params.max) { > > maxResults(Integer.valueOf(params.max)) > > } > > } > > render(view:'list', model:[issueList:issueList, issue:new > > Issue()]) > > } > > > > > > > ______________________________________________________________________ > > This email and any files transmitted with it are confidential and > > intended solely for the use of the individual or entity to whom they > > are addressed. If you have received this email in error please > notify > > the system manager. > > > > Katun Corporation -- www.katun.com > > > _____________________________________________________________________ > > > > > --------------------------------------------------------------------- > > To unsubscribe from this list please visit: > > > > http://xircles.codehaus.org/manage_email > > > > > > > > --------------------------------------------------------------------- > To unsubscribe from this list please visit: > > http://xircles.codehaus.org/manage_email > > > ______________________________________________________________________ > This email has been scanned by the MessageLabs Email Security System. > For more information please visit http://www.messagelabs.com/email > ______________________________________________________________________ > > ______________________________________________________________________ > This email and any files transmitted with it are confidential and > intended solely for the use of the individual or entity to whom they > are addressed. If you have received this email in error please notify > the system manager. > > Katun Corporation -- www.katun.com > _____________________________________________________________________ > > --------------------------------------------------------------------- > To unsubscribe from this list please visit: > > http://xircles.codehaus.org/manage_email > > --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email |
| Powered by Nabble | Edit this page |
