Friday, July 27, 2007
Terminal shell in eclipse
The state of working with Grails in Eclipse is not the best for me. Using the external tool call has been a pain and I have been using an external terminal shell. Today I went looking for a terminal shell solution built into Eclipse and found the Target Management Project.
You can install the components for this via the Eclipse update manager with the information from: http://europa-mirror1.eclipse.org/dsdp/tm/updates/.
Once this is done use the menu sequence Window -> Show_View -> Other and select the Remote Systems folder. From there I added "Remote System Details" (not really needed) and "Remote Shell". Using the triangle menu for this latter element I selected the default local connection.
After all this though.. failure.. it exec's each command out to the shell and as such there is no way to re-attach and kill a process easily. If you run grails run-app it's disconnected to one has to ps its PID and kill it. (not optimal).
After some looking I found sshView (http://www.eclipse-plugins.info/eclipse/plugin_details.jsp?id=1187). This installed but gave some very strange behavior and never was able to get it to successfully work. You can access it in the same sequence as above and look for sshview.
In the end there is easyShell. However, all this does is launch the shell I was using when I started this journey. Yes, you can configure it to open up in the directory the file is in and you can get to rather easily through the contextual menu. In the end not really worth the time and effort and still no good built into the IDE view shell solutions that I can find at least.
Thursday, July 19, 2007
Using Grails GSP to provide alternating colors in a table
Using Grails GSP to provide alternating colors in a table
I saw something related to this a while ago on the net but was not able to find it again. So I just came up with my own approach.
I wanted a table that had alternating rows highlighted. There are many ways to approach this. This solution is what I am going to use since it all falls on the view side of things and as such is rather easy to code. It is based on the code examples from http://grails.org/GSP+Tag+-+set
<table width="50%" align="right" border="0" cellpaddinng="0" cellspacing="0">
<g:def var="counter" value="${1}" />
<g:each in="${lastElement}">
<tr>
<td style="background:${counter % 2 == 0 ? 'white' : 'grey'">
<g:showElementResults id='${it.id}'/>
</td>
</tr>
<g:set var="counter" value="${counter + 1}" />
</g:each>
</table>
It is the "${counter % 2 == 0 ? 'white' : 'grey'}" that does all the work. The only other interesting elements are in bold. Simply change the two colors to get the banding effect you want. A more advanced version of this could set a style name or some other CSS element to improve the approach. I am sure there are several ways to do this. This seems to work for me. The "<g:showElementResults id='${it.id}'/>" code is not relevant here. It's just a taglib I use to create the formatted text of the cell based on an id and the rest is the just the <g:each> tag boilerplate.
I saw something related to this a while ago on the net but was not able to find it again. So I just came up with my own approach.
I wanted a table that had alternating rows highlighted. There are many ways to approach this. This solution is what I am going to use since it all falls on the view side of things and as such is rather easy to code. It is based on the code examples from http://grails.org/GSP+Tag+-+set
<table width="50%" align="right" border="0" cellpaddinng="0" cellspacing="0">
<g:def var="counter" value="${1}" />
<g:each in="${lastElement}">
<tr>
<td style="background:${counter % 2 == 0 ? 'white' : 'grey'">
<g:showElementResults id='${it.id}'/>
</td>
</tr>
<g:set var="counter" value="${counter + 1}" />
</g:each>
</table>
It is the "${counter % 2 == 0 ? 'white' : 'grey'}" that does all the work. The only other interesting elements are in bold. Simply change the two colors to get the banding effect you want. A more advanced version of this could set a style name or some other CSS element to improve the approach. I am sure there are several ways to do this. This seems to work for me. The "<g:showElementResults id='${it.id}'/>" code is not relevant here. It's just a taglib I use to create the formatted text of the cell based on an id and the rest is the just the <g:each> tag boilerplate.
Thursday, July 12, 2007
Keyboard shortcut for grails external tool in Eclipse
Somehow I think this should have been much easier to do. Since it didn't seem to be I am placing it here.
Using Grails in Eclipse (IDE integration information here), I wanted to make a shortcut for the external tools command which is used so much in this set up.
To do this you need to go to preferences (under the window menu), and select Keys -> Modify (Tab) -> Run/Debug (Category pull down) -> Run Last Launched External Tool (Name pull down) then assign the key in the key sequence and be sure to click the "Add" button.
Once all that is done you have a keyboard shortcut for the external tool.
(Please.. I'd like to see netbeans and grails integration)
Subscribe to:
Posts (Atom)