tag:blogger.com,1999:blog-32235227051790950732024-03-08T03:33:59.316-08:00Computer Tips and Tricks from Biniam... where programming tips on Java, Android, MySql and more are shared.Anonymoushttp://www.blogger.com/profile/11965306538365617369noreply@blogger.comBlogger76125tag:blogger.com,1999:blog-3223522705179095073.post-22656166820923496032018-08-22T06:50:00.003-07:002018-08-22T06:51:18.437-07:00My tech experience in Addis Ababa<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="background-color: white; line-height: 1.5999959999999998; margin-bottom: 8pt; margin-top: 0pt; text-align: center;">
<span style="color: #757575; font-family: "arial"; font-size: 10.5pt; text-align: left; vertical-align: baseline; white-space: pre-wrap;">Posted on </span><a href="https://biniamtech.wordpress.com/2016/10/20/my-tech-experience-in-addis-ababa/" style="background-color: transparent; text-align: left; text-decoration-line: none;"><span style="color: #1279be; font-family: "arial"; font-size: 10.5pt; vertical-align: baseline; white-space: pre-wrap;">October 20, 2016</span></a><span style="color: #757575; font-family: "arial"; font-size: 10.5pt; text-align: left; vertical-align: baseline; white-space: pre-wrap;"> by </span><span style="background-color: transparent; color: #1279be; font-family: "arial"; font-size: 10.5pt; text-align: left; vertical-align: baseline; white-space: pre-wrap;"><a href="https://biniamtech.wordpress.com/author/biniamasnake/" style="background-color: transparent; text-align: left; text-decoration-line: none;">biniamasnake</a></span></div>
<b id="docs-internal-guid-789d9d1e-7fff-0544-8023-e0fadef28f17" style="font-weight: normal;"><br /></b>
<br />
<div style="background-color: white; line-height: 1.38; margin-bottom: 18pt; margin-top: 0pt; text-align: left;">
<span style="background-color: transparent;">This post is inspired by Abou Kone‘s interesting article.</span></div>
<br />
I relate to all of the points he mentioned and I would like to describe my experience in the other side of Africa – East Africa.<br />
<br />
At the beginning of January 2016, I started my journey from Berlin, Germany to Addis Ababa, Ethiopia (East Africa) to work remotely and give training to Addis Ababa University lecturers and graduating students on “Agile software development with Grails Framework” with a practical introduction to GitHub, TravisCI and Heroku including other project management tools.<br />
<br />
The Good<br />
<br />
I was happy to be home with my family and enjoying the light winter. It really feels good to be people who look like you and speak the same language. I was amazed by the 3G internet connection speed provided by Ethio Telecom. I had no trouble connecting to the company VPN.<br />
<br />
Among the working spaces in Addis, I really like XHub (http://xhubaddis.tumblr.com/). They are friendly people and also provide good internet connection.<br />
<br />
The Bad<br />
<br />
I also faced the same challenge as you did.<br />
<br />
I also got a subscription of 4GB internet for around 27 Dollars or 25 Euro/month. Although the connection was fast, it is very expensive compared to what I pay in Berlin (300GB internet for 19.99 Euro/month).<br />
<br />
Plus, the internet connection at the university was very slow, we could not open github or Trello.<br />
<br />
The knowledge gap is also very obvious and most people use C# or PHP programming languages as they are given as a course in colleges but they are not aware of frameworks or methodologies.<br />
<br />
Even companies that claim using Agile (be it SCRUM or KANBAN) are not.<br />
<br />
Some challenge I faced which is specific to training is some students were not motivated while the training is one of a kind (as it is practical and focusing on tools/technologies used by Silicon Valley companies and it was FREE).<br />
<br />
I was amazed why the students did not show the expected interest. I guess the reasons could be:<br />
<br />
1. It was given for free so they might assume it is not important.<br />
<br />
2. They don’t really understand how important it is to use/follow methodologies, frameworks and tools and they just want to develop software they know how (and don’t want to learn and follow industry standards).<br />
<br />
3. Maybe the students in my class are not a good sample to infer that there is less interest.<br />
<br />
Summary<br />
<br />
I really admire the initiative by Coders4Africa and Gebeya.com as it is working on finding a solution to a real problem. I am happy to see the milestones achieved and I will be a contributor soon.</div>
Anonymoushttp://www.blogger.com/profile/17067107539206933476noreply@blogger.com0tag:blogger.com,1999:blog-3223522705179095073.post-37382203332912380392016-08-07T14:39:00.002-07:002016-08-07T14:39:39.417-07:00Git: How to delete the last commit on remote<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="background-color: white; border: 0px; clear: both; color: #242729; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px; line-height: 19.5px; margin-bottom: 1em; padding: 0px;">
Let's say you accidentally commited a wrong commit to a branch or a commit to the wrong branch. What do you do?</div>
<div style="background-color: white; border: 0px; clear: both; color: #242729; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px; line-height: 19.5px; margin-bottom: 1em; padding: 0px;">
Thankfully, Git allows you to delete the commit on remote.</div>
<div style="background-color: white; border: 0px; clear: both; color: #242729; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px; line-height: 19.5px; margin-bottom: 1em; padding: 0px;">
Here is how.</div>
<div style="background-color: white; border: 0px; clear: both; color: #242729; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px; line-height: 19.5px; margin-bottom: 1em; padding: 0px;">
<pre style="background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: "arial"; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> git pull origin mybranch
git reset HEAD^ --hard
git push origin-f mybranch
</code></pre>
</div>
<div style="background-color: white; border: 0px; clear: both; color: #242729; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px; line-height: 19.5px; margin-bottom: 1em; padding: 0px;">
More detailed info can be found <a href="http://christoph.ruegg.name/blog/git-howto-revert-a-commit-already-pushed-to-a-remote-reposit.html" rel="nofollow" style="border: 0px; color: #005999; cursor: pointer; margin: 0px; padding: 0px; text-decoration: none;">here</a>.</div>
</div>
Anonymoushttp://www.blogger.com/profile/17067107539206933476noreply@blogger.com0tag:blogger.com,1999:blog-3223522705179095073.post-63322221208490293582016-05-13T02:19:00.002-07:002016-05-13T02:21:29.418-07:00Grails - How to download zip manually and install using SDKMan<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: "georgia" , "times new roman" , serif;">I tried to download the grails using <a href="http://sdkman.io/">SDKMan</a> with:</span><br />
<br />
<div class="p1">
<pre style="background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: "arial"; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><span class="s1"><span style="font-family: "georgia" , "times new roman" , serif;"><code style="color: black; word-wrap: normal;"> sdk install grails 2.5.4
</code></span></span></pre>
</div>
<div class="p1">
<span style="font-family: "georgia" , "times new roman" , serif;">but it failed because of slow internet connection.</span></div>
<div class="p1">
<span style="font-family: "georgia" , "times new roman" , serif;"><br /></span></div>
<div class="p1">
<span style="font-family: "georgia" , "times new roman" , serif;">Then, I went directly to <a href="https://grails.org/download.html">grails.org</a> and downloaded the zip file and added it to /Users/<username>/.sdkman/archives/</span></div>
<div class="p1">
<span style="font-family: "georgia" , "times new roman" , serif;"><br /></span></div>
<div class="p1">
<span style="font-family: "georgia" , "times new roman" , serif;">To install the plugin, run </span></div>
<div class="p1">
<span style="font-family: "georgia" , "times new roman" , serif;"></span><br />
<pre style="background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: "arial"; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><span style="font-family: "georgia" , "times new roman" , serif;"><code style="color: black; word-wrap: normal;"> sdk install grails 2.5.4
</code></span></pre>
</div>
<div class="p1">
<span style="font-family: "georgia" , "times new roman" , serif;"><br /></span></div>
<div class="p1">
<span style="font-family: "georgia" , "times new roman" , serif;">Done!</span></div>
<div class="p1">
<span style="font-family: "georgia" , "times new roman" , serif;"><br /></span></div>
<div class="p1">
<span style="font-family: "georgia" , "times new roman" , serif;">To see if the plugin is installed,</span></div>
<div class="p1">
<span style="font-family: "georgia" , "times new roman" , serif;"></span><br />
<pre style="background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: "arial"; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><span style="font-family: "georgia" , "times new roman" , serif;"><code style="color: black; word-wrap: normal;"> sdk list grails
</code></span></pre>
</div>
</div>
Anonymoushttp://www.blogger.com/profile/17067107539206933476noreply@blogger.com0tag:blogger.com,1999:blog-3223522705179095073.post-60667899479729519462016-04-15T22:17:00.000-07:002016-04-15T22:17:06.649-07:00How to convert Geez-1 font to Unicode<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: left;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: left;">
</div>
<ol style="text-align: left;">
<li><span style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">Download the</span><span style="background-color: white; color: #222222; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; line-height: 14.6667px;"> mapping files that were created for converting </span><span class="Em" style="background-color: white; color: #222222; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; font-style: italic; line-height: 14.6667px;">data</span><span style="background-color: white; color: #222222; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; line-height: 14.6667px;"> to Unicode from </span><a href="http://scripts.sil.org/cms/scripts/render_download.php?format=file&media_id=Geez-1&filename=Geez-1.zip" style="background-color: white; color: #660099; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; line-height: 14.6667px; text-decoration: none;">Download "Geez-1.zip"</a><span style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"> and extract the zip file</span></li>
<li><span style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">Download </span><span style="background-color: white; color: #222222; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; line-height: 14.6667px;">TECkit which is a low-level toolkit intended to be used by other applications that need to perform encoding conversions from </span><a href="http://scripts.sil.org/TECkitDownloads" style="background-color: white; color: red; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; line-height: 14.6667px;">http://scripts.sil.org/TECkitDownloads</a><span style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"> for the platform/operating system you have and install it. You can find the installation notes from the same link.</span></li>
<li><span style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">Go to command line/terminal/command prompt and follow instructions from </span><a href="http://scripts.sil.org/cms/scripts/render_download.php?format=file&media_id=TECkitversion2_doc_pdf&filename=TECkitversion2_doc_pdf.pdf" style="background-color: white; color: #660099; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; line-height: 14.6667px; text-decoration: none;">Download "TECkitversion2_doc_pdf.pdf"</a></li>
</ol>
<br />
<div style="text-align: left;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: left;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">What I did is, I extracted the mapping files in 'Desktop' and put the file with Geez-1 font (to be converted) in 'Desktop' as well. Then, I run the following command in terminal.</span></div>
<div style="text-align: left;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;">txtconv -t Ge\'ez-1.tec -i ToBeConverted.doc -o Converted.txt</span></div>
<div style="text-align: left;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: left;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Note: I have seen that converting .doc (word documents) works better than .txt (plain text files).</span></div>
<div style="text-align: left;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: left;">
<br /></div>
<br /></div>
Anonymoushttp://www.blogger.com/profile/17067107539206933476noreply@blogger.com0tag:blogger.com,1999:blog-3223522705179095073.post-4538932779121544362016-04-15T05:44:00.002-07:002016-04-15T05:44:44.805-07:00Multiple datasource in Grails Services with SQL<div dir="ltr" style="text-align: left;" trbidi="on">
Code talks more than blog post!<br />
<br />
Here is an example code with 2 MySql datasources and getting data from the second datasource using Groovy SQL.<br />
<br />
<a href="https://gist.github.com/biniama/ed9e397b374211d7933b4f5c34e20f48">https://gist.github.com/biniama/ed9e397b374211d7933b4f5c34e20f48</a><br />
<br />
More reading:<br />
<a href="http://grails.github.io/grails-doc/2.5.0/guide/single.html#multipleDatasources">http://grails.github.io/grails-doc/2.5.0/guide/single.html#multipleDatasources </a><a href="https://orkus.wordpress.com/2012/11/11/setup-multiple-data-sources-in-grails-2/">https://orkus.wordpress.com/2012/11/11/setup-multiple-data-sources-in-grails-2/</a><br />
<a href="http://peedeebeesblog.blogspot.de/2015/04/grails-multiple-data-sources-and-plain.html?showComment=1460720540479">http://peedeebeesblog.blogspot.de/2015/04/grails-multiple-data-sources-and-plain.html?showComment=1460720540479</a></div>
Anonymoushttp://www.blogger.com/profile/17067107539206933476noreply@blogger.com0tag:blogger.com,1999:blog-3223522705179095073.post-40997265220873391922015-07-10T06:01:00.001-07:002015-07-10T06:01:17.337-07:00How to debug Grails version greater than 2.4.4 in Intellij<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
Add the following to VM Options of the run configurations (locate the installation of grails) <br />
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQoURTYi5poNc1gleyFb1eLuzc9HaQ1fgcsOYdiDl-u7yxhlSkK9Sn3tACpAfTQjLXs9_TRlEf-ZnjUHJ3SLtfD_L1HNPKNunW-kZRJV3DM6-WgDJgO14X3XAHy-HUf7nGS6KQwnI740it/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> -javaagent:/Users/<username>/.gvm/grails/2.5.0/lib/org.springframework/springloaded/jars/springloaded-1.2.3.RELEASE.jar
-Xverify:none
</code></pre>
</div>
Anonymoushttp://www.blogger.com/profile/17067107539206933476noreply@blogger.com0tag:blogger.com,1999:blog-3223522705179095073.post-6404775074104667162015-03-17T01:55:00.006-07:002015-03-17T01:55:40.242-07:00Solved: MySQL Issue Connection using old (pre-4.1.1) authentication protocol refused.<div dir="ltr" style="text-align: left;" trbidi="on">
The following error occured when run `mysql` from the terminal to connect to a server.<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">mysqldump: Got error: 2049: Connection using old (pre-4.1.1) authentication protocol refused (client option 'secure_auth' enabled) when trying to connect</span><br />
<span style="font-family: Courier New, Courier, monospace;">ERROR 2049 (HY000): Connection using old (pre-4.1.1) authentication protocol refused (client option 'secure_auth' enabled)</span><br />
<br />
Solution:<br />
Add `<span style="font-family: Courier New, Courier, monospace;">--skip-secure-auth</span>` to the end of the statement<br />
<br />
Example:<br />
<span style="font-family: Courier New, Courier, monospace;">mysql -h HostName -u UserName -pPassword DbName --skip-secure-auth</span></div>
Anonymoushttp://www.blogger.com/profile/17067107539206933476noreply@blogger.com0tag:blogger.com,1999:blog-3223522705179095073.post-46985705743951597222015-01-28T03:29:00.003-08:002015-01-28T05:49:14.788-08:00IntelliJ - the intelligent and best IDE for Java Based Projects (such as Grails)<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Trebuchet MS, sans-serif;">Based on my personal experience, the advantages of using IntelliJ than other IDEs are:</span><br />
<br />
<ol style="text-align: left;">
<li><span style="font-family: 'Trebuchet MS', sans-serif;">Support for frameworks and languages such as Grails, Groovy (and more)</span></li>
<li><span style="font-family: 'Trebuchet MS', sans-serif;">Support for debugging grails is amazing</span><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0ICmze6th04hu-7dUssasfrIZyCg0jCHkC7VyZKaNZVYykI5NbERpE_Le_MeNl90mX3ooMrsfI_twwKdKDggUaZbzijpVHZ3qE8WTREix5pHPz_XZxH5LcdVckdppRoj9yLlv6CP5oW0/s1600/debugging.png" imageanchor="1" style="font-family: 'Trebuchet MS', sans-serif; margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0ICmze6th04hu-7dUssasfrIZyCg0jCHkC7VyZKaNZVYykI5NbERpE_Le_MeNl90mX3ooMrsfI_twwKdKDggUaZbzijpVHZ3qE8WTREix5pHPz_XZxH5LcdVckdppRoj9yLlv6CP5oW0/s1600/debugging.png" height="362" width="400" /><a name='more'></a></a></li>
<li><span style="font-family: 'Trebuchet MS', sans-serif;">Visual data/class model presentation<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAi7aCGu10zf3IhSugdJDHBaTOqmlS0fNP-Z6ZFz1XqKy2sY1Du3T65R6jVcN6YmToEOb-oU97iIzfMS8rqesXPeDF7NKEZ0CG45v4aEc3iEjlBbnL-ppE_oppDgsX6a8DiF1pn2XFFDE/s1600/mubs_db_diagram.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAi7aCGu10zf3IhSugdJDHBaTOqmlS0fNP-Z6ZFz1XqKy2sY1Du3T65R6jVcN6YmToEOb-oU97iIzfMS8rqesXPeDF7NKEZ0CG45v4aEc3iEjlBbnL-ppE_oppDgsX6a8DiF1pn2XFFDE/s1600/mubs_db_diagram.png" height="400" width="388" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXRrYVy-CqknRyjXb6WXaNTSsNDgDAGwhzrxj0kGl0a10jXXzw1U-6KU2DbVXeTJ4_b6JPZIBgax1Lduw94lfEUuQ53VHAoC2WXsZGwLzPDPr4kI3o7T1yL3Xxg6QfoXb1y6ahsQtNlSo/s1600/diagram_domain_class_dependencies.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXRrYVy-CqknRyjXb6WXaNTSsNDgDAGwhzrxj0kGl0a10jXXzw1U-6KU2DbVXeTJ4_b6JPZIBgax1Lduw94lfEUuQ53VHAoC2WXsZGwLzPDPr4kI3o7T1yL3Xxg6QfoXb1y6ahsQtNlSo/s1600/diagram_domain_class_dependencies.png" height="305" width="400" /></a></div>
</span></li>
<li><span style="font-family: 'Trebuchet MS', sans-serif;">The 'double shift' searching finds anything in your project with fast speed and accuracy<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0aXUVb8EKuBgW0GGDlSMEyxVXw8ILEDDXUL9KCYNgx0NfoNGIpbv9mHXmp2oTHvFxJZ3hAhyTEozmTyA9gkWRiU7XtrU5Qk4tdaURbybgraKuahtomL8WAfbVkkG6TqRe0nacmFUWLUc/s1600/searching.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0aXUVb8EKuBgW0GGDlSMEyxVXw8ILEDDXUL9KCYNgx0NfoNGIpbv9mHXmp2oTHvFxJZ3hAhyTEozmTyA9gkWRiU7XtrU5Qk4tdaURbybgraKuahtomL8WAfbVkkG6TqRe0nacmFUWLUc/s1600/searching.png" height="143" width="400" /></a></div>
</span></li>
<li><span style="font-family: 'Trebuchet MS', sans-serif;">Generating Controllers and Views can not be easier.<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtXiI1tnoYjGo7GpKF4LXbQpZQK8NFgv8-mXcZ5VIZNjmQWzK6oHseWIdIF6EgzYFWuApD4glcWyDRuGN_feczVOUu7Q7nS_-ge1wFkM9V_WCB_LX87CRsuGxxzy2PsxW89P3icOLrLZg/s1600/generate_controller.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtXiI1tnoYjGo7GpKF4LXbQpZQK8NFgv8-mXcZ5VIZNjmQWzK6oHseWIdIF6EgzYFWuApD4glcWyDRuGN_feczVOUu7Q7nS_-ge1wFkM9V_WCB_LX87CRsuGxxzy2PsxW89P3icOLrLZg/s1600/generate_controller.png" height="283" width="400" /></a></div>
</span></li>
<li><span style="font-family: 'Trebuchet MS', sans-serif;">Faster than Eclipse/STS/GGTS</span></li>
<li><span style="font-family: 'Trebuchet MS', sans-serif;">Consumes less memory than Eclipse/STS/GGTS</span></li>
<li><span style="font-family: 'Trebuchet MS', sans-serif;">Do not crash as much</span></li>
<li><span style="font-family: 'Trebuchet MS', sans-serif;">The look and feel is magnificent (specially the 'Dark' View)<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZXn7Q4I7VglInpRZcLvQInOZ9p4ayPwoxrpm2ZgEagQ18hEK8VkNWZLfipYgiYy4DT4w6XS9Eur9Ir0L_37IAjZ3eMjWmv_Rp1TXQioD4wQ6r7odzabbx14au7EmfOCptKnTEmBWtaZM/s1600/spring-frameworks-1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZXn7Q4I7VglInpRZcLvQInOZ9p4ayPwoxrpm2ZgEagQ18hEK8VkNWZLfipYgiYy4DT4w6XS9Eur9Ir0L_37IAjZ3eMjWmv_Rp1TXQioD4wQ6r7odzabbx14au7EmfOCptKnTEmBWtaZM/s1600/spring-frameworks-1.png" height="240" width="400" /></a></div>
</span></li>
</ol>
<br />
<span style="font-family: Trebuchet MS, sans-serif; font-size: large;">Check out the comparisons presented below. </span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;"><a href="http://java.dzone.com/articles/why-idea-better-eclipse%20%C2%A0">http://java.dzone.com/articles/why-idea-better-eclipse </a> </span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;"><a href="https://plumbr.eu/blog/why-we-dropped-eclipse-in-favour-of-intellij">https://plumbr.eu/blog/why-we-dropped-eclipse-in-favour-of-intellij</a> </span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;"><a href="http://zeroturnaround.com/rebellabs/getting-started-with-intellij-idea-as-an-eclipse-user/">http://zeroturnaround.com/rebellabs/getting-started-with-intellij-idea-as-an-eclipse-user/</a> </span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;"><a href="http://blog.diniscruz.com/2014/03/why-does-eclipse-doesnt-stand-up-more.html">http://blog.diniscruz.com/2014/03/why-does-eclipse-doesnt-stand-up-more.html</a> </span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;"><a href="http://martinfowler.com/bliki/PostIntelliJ.html">http://martinfowler.com/bliki/PostIntelliJ.html</a> </span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><a href="https://www.blogger.com/goog_264777742"><br /></a></span>
<span style="font-family: Trebuchet MS, sans-serif;"><a href="http://www.javacodegeeks.com/2012/01/intellij-vs-eclipse.html">http://www.javacodegeeks.com/2012/01/intellij-vs-eclipse.html</a> </span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;"><a href="http://stackoverflow.com/questions/239732/things-possible-in-intellij-that-arent-possible-in-eclipse">http://stackoverflow.com/questions/239732/things-possible-in-intellij-that-arent-possible-in-eclipse</a> </span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;"><a href="https://wiki.eclipse.org/IDE/Criticism">https://wiki.eclipse.org/IDE/Criticism</a> </span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;"><a href="http://raibledesigns.com/rd/entry/why_i_prefer_intellij_idea">http://raibledesigns.com/rd/entry/why_i_prefer_intellij_idea</a> </span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;"><a href="https://software2cents.wordpress.com/2013/04/17/eclipse-vs-intellij-idea-a-matter-of-little-things/">https://software2cents.wordpress.com/2013/04/17/eclipse-vs-intellij-idea-a-matter-of-little-things/</a> </span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;"><a href="http://nealbuerger.com/2014/06/the-cost-of-using-eclipse-vs-intellij/">http://nealbuerger.com/2014/06/the-cost-of-using-eclipse-vs-intellij/</a> </span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;"><a href="http://www.reddit.com/r/java/comments/1hms60/is_intellij_idea_community_any_good_im_sick_of/">http://www.reddit.com/r/java/comments/1hms60/is_intellij_idea_community_any_good_im_sick_of/</a> </span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;"><a href="http://www.reddit.com/r/java/comments/1en9ac/is_intellij_better_than_netbeans/">http://www.reddit.com/r/java/comments/1en9ac/is_intellij_better_than_netbeans/</a> </span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;"><a href="http://jaxenter.com/eclipse-netbeans-or-intellij-which-is-the-best-java-ide-107980.html">http://jaxenter.com/eclipse-netbeans-or-intellij-which-is-the-best-java-ide-107980.html</a> </span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;"><a href="http://mobiledevices.about.com/od/additionalresources/fl/Comparing-Java-IDEs-Eclipse-vs-NetBeans-vs-IntelliJ.htm">http://mobiledevices.about.com/od/additionalresources/fl/Comparing-Java-IDEs-Eclipse-vs-NetBeans-vs-IntelliJ.htm</a> </span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;"><a href="http://www.martijndashorst.com/blog/2013/11/04/intellij-not-the-best-for-me/">http://www.martijndashorst.com/blog/2013/11/04/intellij-not-the-best-for-me/</a> </span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;"><a href="http://developer4life.blogspot.com/2012/01/intellij-vs-eclipse.html">http://developer4life.blogspot.com/2012/01/intellij-vs-eclipse.html</a> </span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;"><a href="http://jdevelopment.nl/intellij-ide-wanted-love/">http://jdevelopment.nl/intellij-ide-wanted-love/</a> </span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;"><a href="https://groups.google.com/forum/#!topic/scala-ide-user/HmVOegbz6_8">https://groups.google.com/forum/#!topic/scala-ide-user/HmVOegbz6_8</a> </span><br />
<div>
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span></div>
<div>
<br /></div>
</div>
Anonymoushttp://www.blogger.com/profile/17067107539206933476noreply@blogger.com0tag:blogger.com,1999:blog-3223522705179095073.post-78874298651170356732014-12-18T05:13:00.001-08:002014-12-18T05:21:15.474-08:00Sample Web-service method in Groovy and how to call it<div dir="ltr" style="text-align: left;" trbidi="on">
<div>
You might have heard about Webservice.<br />
<br />
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQoURTYi5poNc1gleyFb1eLuzc9HaQ1fgcsOYdiDl-u7yxhlSkK9Sn3tACpAfTQjLXs9_TRlEf-ZnjUHJ3SLtfD_L1HNPKNunW-kZRJV3DM6-WgDJgO14X3XAHy-HUf7nGS6KQwnI740it/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> Don't just use facebook or twitter or google! </code></pre>
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQoURTYi5poNc1gleyFb1eLuzc9HaQ1fgcsOYdiDl-u7yxhlSkK9Sn3tACpAfTQjLXs9_TRlEf-ZnjUHJ3SLtfD_L1HNPKNunW-kZRJV3DM6-WgDJgO14X3XAHy-HUf7nGS6KQwnI740it/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> Understand how things work in the background. </code></pre>
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQoURTYi5poNc1gleyFb1eLuzc9HaQ1fgcsOYdiDl-u7yxhlSkK9Sn3tACpAfTQjLXs9_TRlEf-ZnjUHJ3SLtfD_L1HNPKNunW-kZRJV3DM6-WgDJgO14X3XAHy-HUf7nGS6KQwnI740it/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> Read this short blog post I wrote to learn how the pages you see and the mobile </code></pre>
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQoURTYi5poNc1gleyFb1eLuzc9HaQ1fgcsOYdiDl-u7yxhlSkK9Sn3tACpAfTQjLXs9_TRlEf-ZnjUHJ3SLtfD_L1HNPKNunW-kZRJV3DM6-WgDJgO14X3XAHy-HUf7nGS6KQwnI740it/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> apps you use communicate with servers.
</code></pre>
<span style="background-color: white; color: #252525; font-family: sans-serif; font-size: 14px; line-height: 22px;"><br /></span>
<span style="background-color: white; color: #252525; font-family: sans-serif; font-size: 14px; line-height: 22px;">A </span><b style="background-color: white; color: #252525; font-family: sans-serif; font-size: 14px; line-height: 22px;">Web service</b><span style="background-color: white; color: #252525; font-family: sans-serif; font-size: 14px; line-height: 22px;"> is a method of communication between two electronic devices over a </span><a href="http://en.wikipedia.org/wiki/Computer_network" style="background-image: none; background-position: initial initial; background-repeat: initial initial; color: #0b0080; text-decoration: none;" title="Computer network">network</a><span style="background-color: white; color: #252525; font-family: sans-serif; font-size: 14px; line-height: 22px;">. It is a software function provided at a network address over the Web with the service </span><i style="background-color: white; color: #252525; font-family: sans-serif; font-size: 14px; line-height: 22px;">always on</i><span style="background-color: white; color: #252525; font-family: sans-serif; font-size: 14px; line-height: 22px;"> as in the concept of </span><a href="http://en.wikipedia.org/wiki/Utility_computing" style="background-image: none; background-position: initial initial; background-repeat: initial initial; color: #0b0080; text-decoration: none;" title="Utility computing">utility computing</a><span style="background-color: white; color: #252525; font-family: sans-serif; font-size: 14px; line-height: 22px;">. The </span><a class="mw-redirect" href="http://en.wikipedia.org/wiki/W3C" style="background-image: none; background-position: initial initial; background-repeat: initial initial; color: #0b0080; text-decoration: none;" title="W3C">W3C</a><span style="background-color: white; color: #252525; font-family: sans-serif; font-size: 14px; line-height: 22px;"> defines a Web service generally as:-</span><br />
<blockquote class="templatequote bq" style="background-color: white; color: #252525; font-family: sans-serif; font-size: 14px; line-height: 22px; margin-top: 1em; overflow: hidden;">
<div style="line-height: inherit; margin-bottom: 0.5em; margin-top: 0.5em;">
a software system designed to support <a href="http://en.wikipedia.org/wiki/Interoperability" style="background-image: none; background-position: initial initial; background-repeat: initial initial; color: #0b0080; text-decoration: none;" title="Interoperability">interoperable</a> machine-to-machine interaction over a <a href="http://en.wikipedia.org/wiki/Computer_network" style="background-image: none; background-position: initial initial; background-repeat: initial initial; color: #0b0080; text-decoration: none;" title="Computer network">network</a>.</div>
</blockquote>
Read what web services are from <a href="http://en.wikipedia.org/wiki/Web_service">wikipedia </a>and read the code.<br />
<br />
Nowadays, This is how almost all new web and mobile apps work.</div>
<div>
<br /></div>
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQoURTYi5poNc1gleyFb1eLuzc9HaQ1fgcsOYdiDl-u7yxhlSkK9Sn3tACpAfTQjLXs9_TRlEf-ZnjUHJ3SLtfD_L1HNPKNunW-kZRJV3DM6-WgDJgO14X3XAHy-HUf7nGS6KQwnI740it/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> class SampleController {
def action(String username, String course, String password){
return Grade.findByUsernameAndCourseAndPassword(username, course, password)
}
}
</code></pre>
<br />
GET<br />
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQoURTYi5poNc1gleyFb1eLuzc9HaQ1fgcsOYdiDl-u7yxhlSkK9Sn3tACpAfTQjLXs9_TRlEf-ZnjUHJ3SLtfD_L1HNPKNunW-kZRJV3DM6-WgDJgO14X3XAHy-HUf7nGS6KQwnI740it/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> www.mu.com/sample/action?username=biniam&course=it&password=123
</code></pre>
<br />
POST<br />
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQoURTYi5poNc1gleyFb1eLuzc9HaQ1fgcsOYdiDl-u7yxhlSkK9Sn3tACpAfTQjLXs9_TRlEf-ZnjUHJ3SLtfD_L1HNPKNunW-kZRJV3DM6-WgDJgO14X3XAHy-HUf7nGS6KQwnI740it/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><span class="Apple-tab-span" style="white-space: pre;"><code style="color: black; word-wrap: normal;"> www.mu.com/sample/action
{
"username":"biniam",
"course":"it",
"password":"123"
}
</code></span></pre>
<span class="Apple-tab-span" style="white-space: pre;">
</span></div>
Anonymoushttp://www.blogger.com/profile/17067107539206933476noreply@blogger.com0tag:blogger.com,1999:blog-3223522705179095073.post-86878435292064205562014-12-16T07:21:00.001-08:002014-12-16T07:21:14.568-08:00Git Commit with Header and Multi-line Body<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Trebuchet MS, sans-serif;">I found this interesting answer on <a href="http://stackoverflow.com/questions/5064563/add-line-break-to-git-commit-m-from-command-line">Stackoverflow</a> to add Git Commit with Header and Multi-line Body and I wanted to share it.</span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;">
</span><br />
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQoURTYi5poNc1gleyFb1eLuzc9HaQ1fgcsOYdiDl-u7yxhlSkK9Sn3tACpAfTQjLXs9_TRlEf-ZnjUHJ3SLtfD_L1HNPKNunW-kZRJV3DM6-WgDJgO14X3XAHy-HUf7nGS6KQwnI740it/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><span style="font-family: Trebuchet MS, sans-serif;"><code style="color: black; word-wrap: normal;"> git commit -m "Header Comes Here" -m "Multiline body Comes Here.
Add a title to your commit after -m enclosed in quotes,
then add the body of your comment after a second -m.
Press ENTER before closing the quotes to add a line break.
Repeat as needed.
Then close the quotes and hit ENTER twice to apply the commit."
</code></span></pre>
<span style="font-family: Trebuchet MS, sans-serif;">
</span>
<br />
Thanks <a href="http://stackoverflow.com/users/138938/jon-crowell" style="background-color: white; border: 0px; color: #4a6b82; cursor: pointer; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 13px; line-height: 17px; margin: 0px; padding: 0px; vertical-align: baseline; white-space: nowrap;">Jon Crowell</a>. </div>
Anonymoushttp://www.blogger.com/profile/17067107539206933476noreply@blogger.com1tag:blogger.com,1999:blog-3223522705179095073.post-14703243034371264492014-11-23T21:13:00.005-08:002014-11-23T21:14:02.350-08:00Bootstrap CSS templating in Grails.<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Trebuchet MS, sans-serif;"><b>There are three ways of integrating Bootstrap CSS templating to Grails.</b></span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;">1. Using twitter bootstrap plugin <a href="http://grails.org/plugin/twitter-bootstrap">grails.org/plugin/twitter-bootstrap</a></span><br />
<span style="font-family: Trebuchet MS, sans-serif;">2. Using kick start bootstrap plugin <a href="http://grails.org/plugin/kickstart-with-bootstrap">grails.org/plugin/kickstart-with-bootstrap</a></span><br />
<span style="font-family: Trebuchet MS, sans-serif;">3. Manually downloading boostrap source files from <a href="http://getbootstrap.com/">getbootstrap.com</a> and putting the files in <b>grails-app/assets</b> (for Grails 2.4.3 and above) or in <b>web-app/css</b> and <b>web-app/js </b>folders</span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;">There is one good blog post about using bootstrap as a default template by Iraklis at <a href="http://foodforcoding.com/2013/05/25/grails-with-twitter-bootstrap/">foodforcoding.com/2013/05/25/grails-with-twitter-bootstrap/</a> (althought the blog entry is old)</span><br />
<span style="font-family: Trebuchet MS, sans-serif;">Another video by Joe Rinehart explains how to integrate Twitter Bootstrap into a Grails application (can be found at <a href="http://www.infoq.com/presentations/grails-twitter-bootstrap/">www.infoq.com/presentations/grails-twitter-bootstrap/</a>)</span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;">The github project of twitter-boostrap plugin at <a href="https://github.com/robfletcher/twitter-bootstrap-scaffolding">https://github.com/robfletcher/twitter-bootstrap-scaffolding</a> is also a good help.</span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;">You can also look at <b>my </b>simple blogging system developed in grails which uses Bootstrap 3 at <a href="https://github.com/biniama/mubs">https://github.com/biniama/mubs</a></span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
</div>
Anonymoushttp://www.blogger.com/profile/17067107539206933476noreply@blogger.com0tag:blogger.com,1999:blog-3223522705179095073.post-11772421665395814902014-11-23T21:11:00.003-08:002014-11-23T21:11:47.719-08:00Importing your git repository from bitbucket (or any other VCS) to GitHub<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Trebuchet MS, sans-serif;">Go to </span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;"> 1. <a href="https://import.github.com/new">https://import.github.com/new</a> and enter the url of the old repository</span><br />
<span style="font-family: Trebuchet MS, sans-serif;"> 2. give it a repository name (or it will import the name automatically)</span><br />
<span style="font-family: Trebuchet MS, sans-serif;"> 3. select public vs private repo</span><br />
<span style="font-family: Trebuchet MS, sans-serif;"> 4. Click import</span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;">Good luck!</span></div>
Anonymoushttp://www.blogger.com/profile/17067107539206933476noreply@blogger.com0tag:blogger.com,1999:blog-3223522705179095073.post-45152727495155453082014-11-21T06:06:00.001-08:002014-11-21T06:17:03.703-08:00Edit/Update Page Implementation in JQuery and Grails<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: 'Trebuchet MS', sans-serif;">I have a page with a form where a user enters first name and last name.</span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;">When the 'Edit' button is clicked, I want the button's name to change to 'Update' and the textboxes to become editable.</span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;">Then, when the user finishes editing the fields, I want to call a controller method in Grails.</span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;">What I want is to call the controller method WHEN 'UPDATE' BUTTON IS CLICKED (NOT WHEN 'EDIT' BUTTON IS CLICKED).</span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;">Here is the solution!</span><br />
<a name='more'></a><br />
<span style="font-family: Trebuchet MS, sans-serif;">I put the edit button outside the tag and when the edit button is clicked, it calls a JQuery function which makes the fields editable and change the background color of the textboxes.</span><br />
<span style="font-family: Trebuchet MS, sans-serif;">Plus, it hides the edit button and show the update button.</span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;">The update button is inside tag and it calls a controller action.</span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;">It works fine and I think this is the best way of implementing this.</span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;">N.B. I had asked this question in <a href="http://stackoverflow.com/">stackoverflow.com</a> and got some hint and I did it. You can find the link <a href="http://stackoverflow.com/questions/25911567/edit-update-page-implementation-in-jquery-and-grails">here</a>.</span><br />
<br />
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQoURTYi5poNc1gleyFb1eLuzc9HaQ1fgcsOYdiDl-u7yxhlSkK9Sn3tACpAfTQjLXs9_TRlEf-ZnjUHJ3SLtfD_L1HNPKNunW-kZRJV3DM6-WgDJgO14X3XAHy-HUf7nGS6KQwnI740it/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;">1: <script>
2: $(document).ready(function(){
3:
4: // Updating Profile
5: $('#editProfile').click(function(){
6:
7: // Make fields editable
8: $('.editableField').prop('disabled', false);
9:
10: $('.editableField').css("background-color", "yellow");
11:
12: // hide the edit button div
13: $('#updateProfileDiv').show();
14:
15: // show the update button div
16: $('#editProfileDiv').hide();
17: });
18:
19: });
20: </script>
21:
22: <!-- Inside the body tag-->
23: <g:form action="updateProfile" >
24: <div id="one">
25: <g:if test="${customerInstance?.firstName}">
26: <div class="fieldcontain">
27: <label for="firstName">
28: <g:message code="admin.customer.profile.firstName.label" default="First Name" />:
29: </label>
30: <g:textField name="firstName" value="${customerInstance?.firstName}" disabled='disabled' class='notEditableField'/>
31: </div>
32: </g:if>
33:
34: <g:if test="${customerInstance?.lastName}">
35: <div class="fieldcontain">
36: <label for="lastName">
37: <g:message code="admin.customer.profile.lastName.label" default="Last Name" />:
38: </label>
39: <g:textField name="lastName" value="${customerInstance?.lastName}" disabled='disabled' class='notEditableField'/>
40: </div>
41: </g:if>
42:
43: <div id="updateProfileDiv" style="display:none">
44: <fieldset class="buttons">
45: <g:hiddenField name="id" value="${customerInstance?.id}" />
46:
47: <g:submitButton class="edit" name="updateProfile"
48: value="${message(code: 'admin.customer.profile.update.profile.button.label', default: 'Update Profile')}"/>
49: </fieldset>
50: </div>
51:
52: </g:form> <!-- end of g:form tag-->
53:
54: <div id="editProfileDiv">
55: <fieldset class="buttons">
56: <g:submitButton class="edit" id="editProfile" name="editProfile"
57: value="${message(code: 'admin.customer.profile.edit.profile.button.label', default: 'Edit Profile')}"/>
58: </fieldset>
59: </div>
</code></pre>
</div>
Anonymoushttp://www.blogger.com/profile/17067107539206933476noreply@blogger.com0tag:blogger.com,1999:blog-3223522705179095073.post-82283341921786215982014-09-26T01:12:00.003-07:002014-09-26T01:33:16.425-07:00Using the asset pipeline grails plugin to write Page Specific Javascript<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Trebuchet MS, sans-serif;">The <a href="http://bertramdev.github.io/asset-pipeline/guide/introduction.html">Grails Asset-Pipeline</a> is a plugin used for managing and processing static assets in Grails applications. </span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;">Asset-Pipeline functions include processing and minification of both CSS and JavaScript files. It is also capable of being extended to compile custom static assets, such as CoffeeScript or LESS.</span><br />
<span style="background-color: white; color: #444444; font-family: Arial; font-size: 14px; line-height: 16px; text-align: justify;"><br /></span>
<span style="background-color: white; color: #444444; line-height: 16px; text-align: justify;"><span style="font-family: Trebuchet MS, sans-serif;">Here is one way of u</span></span><span style="color: #444444; font-family: Trebuchet MS, sans-serif;"><span style="line-height: 16px;">sing the asset pipeline grails plugin to write Page Specific Javascript</span></span><br />
<span style="background-color: white; color: #444444; font-family: Arial; font-size: 14px; line-height: 16px; text-align: justify;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;">specific.js // will be included by default</span><br />
<br />
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQoURTYi5poNc1gleyFb1eLuzc9HaQ1fgcsOYdiDl-u7yxhlSkK9Sn3tACpAfTQjLXs9_TRlEf-ZnjUHJ3SLtfD_L1HNPKNunW-kZRJV3DM6-WgDJgO14X3XAHy-HUf7nGS6KQwnI740it/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> var pageSpecific = function() {
console.log('Hello from specific page!)
});
$(document).ready(function({
if($(document.body).data('page') == 'specific') {
pageSpecific())
}
})); </code></pre>
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;">index.gsp</span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQoURTYi5poNc1gleyFb1eLuzc9HaQ1fgcsOYdiDl-u7yxhlSkK9Sn3tACpAfTQjLXs9_TRlEf-ZnjUHJ3SLtfD_L1HNPKNunW-kZRJV3DM6-WgDJgO14X3XAHy-HUf7nGS6KQwnI740it/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><span class="Apple-tab-span" style="white-space: pre;"><code style="color: black; word-wrap: normal;"> <meta name='layout' content='main'/>
<body data-page="specific">
<h1>Hello from Specific!</h1>
</body>
</code></span></pre>
<br />
<span style="font-family: Trebuchet MS, sans-serif;">main.gsp // modify so that it passes the data-page attribute to the JS (since index.gsp uses main as a layout)</span><br />
<span class="Apple-tab-span" style="font-family: Trebuchet MS, sans-serif; white-space: pre;"> </span><br />
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQoURTYi5poNc1gleyFb1eLuzc9HaQ1fgcsOYdiDl-u7yxhlSkK9Sn3tACpAfTQjLXs9_TRlEf-ZnjUHJ3SLtfD_L1HNPKNunW-kZRJV3DM6-WgDJgO14X3XAHy-HUf7nGS6KQwnI740it/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><span class="Apple-tab-span" style="white-space: pre;"><code style="color: black; word-wrap: normal;"> <body data-page"${pageProperty(name:'body.data-page')}">
// main body content
</body></code></span></pre>
</div>
Anonymoushttp://www.blogger.com/profile/17067107539206933476noreply@blogger.com0tag:blogger.com,1999:blog-3223522705179095073.post-12373392186565867972014-07-23T00:44:00.001-07:002014-07-23T00:51:18.133-07:00jQuery - Enable and Disable Textbox (Make fields editable) and Update Button Value<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Georgia, Times New Roman, serif;">Here is an example of making an input field editable by enabling/disabling it. The example also changes the Value of the submit button from 'Edit' to 'Update'.</span><br />
<span style="font-family: Georgia, Times New Roman, serif;"><br /></span>
<span style="font-family: Georgia, Times New Roman, serif;">You can test the code at this <a href="http://jsfiddle.net/biniama/YDcFF/">JSFiddle</a>.</span><br />
<br />
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQoURTYi5poNc1gleyFb1eLuzc9HaQ1fgcsOYdiDl-u7yxhlSkK9Sn3tACpAfTQjLXs9_TRlEf-ZnjUHJ3SLtfD_L1HNPKNunW-kZRJV3DM6-WgDJgO14X3XAHy-HUf7nGS6KQwnI740it/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> <!DOCTYPE html>
<head>
<title>jQuery enable/disable button</title>
<script type='text/javascript' src='http://code.jquery.com/jquery.min.js'></script>
<script type='text/javascript'>
$(function(){
$('#submitBtn').click(function(){
$('.enableOnInput').prop('disabled', false);
$('#submitBtn').val('Update');
});
});
</script>
<style type='text/css'>
/* Lets use a Google Web Font :) */
@import url(http://fonts.googleapis.com/css?family=Finger+Paint);
/* Basic CSS for positioning etc */
body {
font-family: 'Finger Paint', cursive;
background-image: url('bg.jpg');
}
#frame {
width: 700px;
margin: auto;
margin-top: 125px;
border: solid 1px #CCC;
/* SOME CSS3 DIV SHADOW */
-webkit-box-shadow: 0px 0px 10px #CCC;
-moz-box-shadow: 0px 0px 10px #CCC;
box-shadow: 0px 0px 10px #CCC;
/* CSS3 ROUNDED CORNERS */
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
-khtml-border-radius: 5px;
border-radius: 5px;
background-color: #FFF;
}
#searchInput {
height: 30px;
line-height: 30px;
padding: 3px;
width: 300px;
}
#submitBtn {
height: 40px;
line-height: 40px;
width: 120px;
text-align: center;
}
#frame h1 {
text-align: center;
}
#frame div {
text-align: center;
margin-bottom: 30px;
}
</style>
</head>
<body>
<div id='frame'>
<div class='search'>
<h1>jQuery Enable and Disable button</h1>
<input type='text' name='searchQuery' id='searchInput' class='enableOnInput' disabled='disabled'/>
<input type='submit' name='submit' id='submitBtn' value='Edit'/>
</div>
</div>
</body>
</html>
</code></pre>
</div>
Anonymoushttp://www.blogger.com/profile/17067107539206933476noreply@blogger.com0tag:blogger.com,1999:blog-3223522705179095073.post-74080815200155642852014-07-22T09:08:00.001-07:002014-07-23T00:45:08.022-07:00Grails: CreateCriteria with Projection<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Trebuchet MS, sans-serif;">Here is an example of using createCriteria() function in grails using projection of sum.</span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;">This method returns the sum of Balance in from Finance model/domain.<span class="Apple-tab-span" style="white-space: pre;"> </span></span><br />
<span style="font-family: Trebuchet MS, sans-serif;">You can put this code in Bootstrap.groovy to run it when the program starts.</span><br />
<br />
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQoURTYi5poNc1gleyFb1eLuzc9HaQ1fgcsOYdiDl-u7yxhlSkK9Sn3tACpAfTQjLXs9_TRlEf-ZnjUHJ3SLtfD_L1HNPKNunW-kZRJV3DM6-WgDJgO14X3XAHy-HUf7nGS6KQwnI740it/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> println Finance.createCriteria().list() {
eq('financeType', FinanceTypeEnum.SAVINGS)
projections {
sum('balance')
}
}
</code></pre>
<br />
<br /></div>
Anonymoushttp://www.blogger.com/profile/17067107539206933476noreply@blogger.com0tag:blogger.com,1999:blog-3223522705179095073.post-41254743237455424302014-07-22T07:01:00.001-07:002014-07-22T07:07:25.821-07:00Grails: Displaying image stored in the database on gsp<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Trebuchet MS, sans-serif;">Here is a <a href="http://www.grails.org/">Grails</a> implementation of displaying image stored in the database (as byte[]) on gsp.</span><br />
<b style="font-family: 'Trebuchet MS', sans-serif;"><br /></b>
<b style="font-family: 'Trebuchet MS', sans-serif;">Notes: </b><br />
<br />
<ul style="text-align: left;">
<li><span style="font-family: 'Trebuchet MS', sans-serif;">I have spring security core plugin configured</span></li>
<li><span style="font-family: Trebuchet MS, sans-serif;">The image tag calls the controller's method directly and it uses the apps url and app.name from </span><span style="font-family: Courier New, Courier, monospace;">Config.groovy</span><span style="font-family: Trebuchet MS, sans-serif;"> and</span><span style="font-family: Courier New, Courier, monospace;"> application.properties</span></li>
</ul>
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQoURTYi5poNc1gleyFb1eLuzc9HaQ1fgcsOYdiDl-u7yxhlSkK9Sn3tACpAfTQjLXs9_TRlEf-ZnjUHJ3SLtfD_L1HNPKNunW-kZRJV3DM6-WgDJgO14X3XAHy-HUf7nGS6KQwnI740it/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> FILE: Domain class - SecUser </code></pre>
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQoURTYi5poNc1gleyFb1eLuzc9HaQ1fgcsOYdiDl-u7yxhlSkK9Sn3tACpAfTQjLXs9_TRlEf-ZnjUHJ3SLtfD_L1HNPKNunW-kZRJV3DM6-WgDJgO14X3XAHy-HUf7nGS6KQwnI740it/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;">
class SecUser extends User {
String firstName
String middleName
String lastName
byte [] userPhoto
Date dateCreated
Date lastUpdated
static constraints = {
firstName blank: false
middleName blank: false
lastName blank: false
userPhoto nullable: true, maxSize:1024000
}
String toString() {
if(firstName && middleName && lastName){
return "${firstName} ${middleName} ${lastName}"
} else {
return username
}
}
}</code></pre>
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQoURTYi5poNc1gleyFb1eLuzc9HaQ1fgcsOYdiDl-u7yxhlSkK9Sn3tACpAfTQjLXs9_TRlEf-ZnjUHJ3SLtfD_L1HNPKNunW-kZRJV3DM6-WgDJgO14X3XAHy-HUf7nGS6KQwnI740it/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;">
</code></pre>
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQoURTYi5poNc1gleyFb1eLuzc9HaQ1fgcsOYdiDl-u7yxhlSkK9Sn3tACpAfTQjLXs9_TRlEf-ZnjUHJ3SLtfD_L1HNPKNunW-kZRJV3DM6-WgDJgO14X3XAHy-HUf7nGS6KQwnI740it/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> FILE: MyController </code></pre>
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQoURTYi5poNc1gleyFb1eLuzc9HaQ1fgcsOYdiDl-u7yxhlSkK9Sn3tACpAfTQjLXs9_TRlEf-ZnjUHJ3SLtfD_L1HNPKNunW-kZRJV3DM6-WgDJgO14X3XAHy-HUf7nGS6KQwnI740it/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;">
class DashboardController {
def springSecurityService
def index() {
render(view: 'index')
}
def displayAvatarForCurrentUser() {
User user = springSecurityService.getCurrentUser()
SartUser sartUser = SartUser.findByUsername(user.username)
response.outputStream << sartUser.userPhoto // write the photo to the outputstream
response.outputStream.flush()
}
}
</code></pre>
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQoURTYi5poNc1gleyFb1eLuzc9HaQ1fgcsOYdiDl-u7yxhlSkK9Sn3tACpAfTQjLXs9_TRlEf-ZnjUHJ3SLtfD_L1HNPKNunW-kZRJV3DM6-WgDJgO14X3XAHy-HUf7nGS6KQwnI740it/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> FILE: show.gsp
</code></pre>
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQoURTYi5poNc1gleyFb1eLuzc9HaQ1fgcsOYdiDl-u7yxhlSkK9Sn3tACpAfTQjLXs9_TRlEf-ZnjUHJ3SLtfD_L1HNPKNunW-kZRJV3DM6-WgDJgO14X3XAHy-HUf7nGS6KQwnI740it/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> <div>
<sec:ifLoggedIn>
<img src="${grailsApplication.config?.grails?.serverURL}/dashboard/displayAvatarForCurrentUser"/>
</sec:ifLoggedIn>
%{--If the user has logged in, then the avatar will be shown.--}%
</div> </code></pre>
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQoURTYi5poNc1gleyFb1eLuzc9HaQ1fgcsOYdiDl-u7yxhlSkK9Sn3tACpAfTQjLXs9_TRlEf-ZnjUHJ3SLtfD_L1HNPKNunW-kZRJV3DM6-WgDJgO14X3XAHy-HUf7nGS6KQwnI740it/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;">
FILE: Config.groovy </code></pre>
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQoURTYi5poNc1gleyFb1eLuzc9HaQ1fgcsOYdiDl-u7yxhlSkK9Sn3tACpAfTQjLXs9_TRlEf-ZnjUHJ3SLtfD_L1HNPKNunW-kZRJV3DM6-WgDJgO14X3XAHy-HUf7nGS6KQwnI740it/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;">
environments {
development {
grails.logging.jul.usebridge = true
grails.serverURL = "http://localhost:9090/${appName}"
}
test {
grails.serverURL = "http://localhost</code>/${appName}" </pre>
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQoURTYi5poNc1gleyFb1eLuzc9HaQ1fgcsOYdiDl-u7yxhlSkK9Sn3tACpAfTQjLXs9_TRlEf-ZnjUHJ3SLtfD_L1HNPKNunW-kZRJV3DM6-WgDJgO14X3XAHy-HUf7nGS6KQwnI740it/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> }
production {
grails.logging.jul.usebridge = false
// TODO: grails.serverURL = "http://www.changeme.com</code>/${appName}" </pre>
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQoURTYi5poNc1gleyFb1eLuzc9HaQ1fgcsOYdiDl-u7yxhlSkK9Sn3tACpAfTQjLXs9_TRlEf-ZnjUHJ3SLtfD_L1HNPKNunW-kZRJV3DM6-WgDJgO14X3XAHy-HUf7nGS6KQwnI740it/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> }
} </code></pre>
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQoURTYi5poNc1gleyFb1eLuzc9HaQ1fgcsOYdiDl-u7yxhlSkK9Sn3tACpAfTQjLXs9_TRlEf-ZnjUHJ3SLtfD_L1HNPKNunW-kZRJV3DM6-WgDJgO14X3XAHy-HUf7nGS6KQwnI740it/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;">
FILE: application.properties </code></pre>
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQoURTYi5poNc1gleyFb1eLuzc9HaQ1fgcsOYdiDl-u7yxhlSkK9Sn3tACpAfTQjLXs9_TRlEf-ZnjUHJ3SLtfD_L1HNPKNunW-kZRJV3DM6-WgDJgO14X3XAHy-HUf7nGS6KQwnI740it/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;">
app.name=samplegrailsappname
</code></pre>
<br /></div>
Anonymoushttp://www.blogger.com/profile/17067107539206933476noreply@blogger.com0tag:blogger.com,1999:blog-3223522705179095073.post-82937264031262964542014-06-25T07:39:00.004-07:002014-06-25T07:39:45.104-07:00Solving Error: “syntax error near unexpected token”<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; text-align: center;">
<span style="font-family: 'Trebuchet MS'; font-size: 21px; line-height: 1.15; text-align: left; white-space: pre-wrap;">Detail Error:</span></div>
<div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; text-indent: 36pt;">
<span style="background-color: transparent; color: #262626; font-family: 'Courier New'; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">: command not found </span></div>
<div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; text-indent: 36pt;">
<span style="background-color: transparent; color: #262626; font-family: 'Courier New'; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">: command not found </span></div>
<div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; text-indent: 36pt;">
<span style="background-color: transparent; color: #262626; font-family: 'Courier New'; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">'/build.sh: line 3: syntax error near unexpected token `{</span></div>
<div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; text-indent: 36pt;">
<span style="background-color: transparent; color: #262626; font-family: 'Courier New'; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">'/build.sh: line 3: `function stop_channels(){</span></div>
<b id="docs-internal-guid-27c8e5c4-d376-4668-87e8-1c6a7608ae29" style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">was thrown when I run</span></div>
<div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; text-indent: 36pt;">
<span style="background-color: transparent; color: #262626; font-family: 'Courier New'; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">./build.sh</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: #262626; font-family: Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">The issue was I opened the .sh (shell script) in Windows OS and Windows changed the end of the line to CRLF</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: #262626; font-family: Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">I found this out by running</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; text-indent: 36pt;">
<span style="background-color: transparent; color: #262626; font-family: 'Courier New'; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">cat --show-nonprinting filename.extension</span></div>
<div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: #262626; font-family: Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">E.g.</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; text-indent: 36pt;">
<span style="background-color: transparent; color: #262626; font-family: 'Courier New'; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">cat --show-nonprinting test.sh</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: #262626; font-family: Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Or open the file in </span><span style="background-color: transparent; color: #262626; font-family: Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Notepad++</span><span style="background-color: transparent; color: #262626; font-family: Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> and click on the button circled in the figure below.</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><img alt="windows vs linux.PNG" height="160px;" src="https://lh5.googleusercontent.com/0Pxob45dOvDfUcbEIZfOD3HIS-ujaS2uqjZAYUTqK5Kx6Bv_DdtV8579SK9FLGSIsGJB8vb3WAHpA7skLzmNrX3xihsQajrZPA7p9O1YAWFxIkdypsBGJYRkRZJfmr_PpQ" style="-webkit-transform: rotate(0.00rad); border: none; transform: rotate(0.00rad);" width="590px;" /></span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: #262626; font-family: Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Then, I converted it using</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; text-indent: 36pt;">
<span style="background-color: transparent; color: #262626; font-family: 'Courier New'; font-size: 13px; font-style: normal; font-variant: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">dos2unix filename.extension</span></div>
<div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; text-indent: 36pt;">
<span style="background-color: transparent; color: #262626; font-family: Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">[Install dos2unix if required]</span></div>
<div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: #262626; font-family: Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">E.g.</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; text-indent: 36pt;">
<span style="background-color: transparent; color: #262626; font-family: 'Courier New'; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">dos2unix myfile.txt</span></div>
<div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; text-indent: 36pt;">
<span style="background-color: transparent; color: #262626; font-family: 'Courier New'; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">dos2unix myshell.sh</span></div>
<br /><br /><br /></div>
Anonymoushttp://www.blogger.com/profile/11965306538365617369noreply@blogger.com0tag:blogger.com,1999:blog-3223522705179095073.post-64792919984347304502014-06-12T02:13:00.003-07:002014-06-12T02:15:26.673-07:00Android: Solving "Error:The SDK Build Tools revision (19.0.1) is too low. Minimum required is 19.1.0"<div dir="ltr" style="text-align: left;" trbidi="on">
<pre style="background-color: white; max-width: 80em; padding-left: 0.7em;"><span style="white-space: pre-wrap;"><span style="font-family: Trebuchet MS, sans-serif;">After upgrading <a href="http://developer.android.com/sdk/installing/studio.html" target="_blank">Android Studio</a> to 0.6.0, I got this error
</span><span style="font-family: Courier New, Courier, monospace;">"Error:The SDK Build Tools revision (19.0.1) is too low. Minimum required is 19.1.0"</span><span style="font-family: Trebuchet MS, sans-serif;">
<b>Solution:</b>
Open build.gradle file in your project and change the buildToolsVersion from 19.0.1 to 19.1.0 like:
</span><span style="font-family: Courier New, Courier, monospace;">android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
}</span><span style="font-family: Trebuchet MS, sans-serif;">
Then, Open Android SDK Manager and update the SDK Build-tools by installing version or revision (Rev.) 19.1.</span></span></pre>
<pre style="background-color: white; font-size: 12px; max-width: 80em; padding-left: 0.7em; white-space: pre-wrap;"></pre>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgA8HwuymMX20OvB_ir6bSGxpnBvkiqxYXH8LEOneSI3JOtBGIRC2pk-IWaoT0Tqt68n2jK-TgJ9oLz_kz2O2cFrTVZ6YDEkooErOXWyPdycG4yFnHpwOAIz35Y1XUo5z7wVkyWEgDxmL0/s1600/Android+SDK+Manager.PNG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgA8HwuymMX20OvB_ir6bSGxpnBvkiqxYXH8LEOneSI3JOtBGIRC2pk-IWaoT0Tqt68n2jK-TgJ9oLz_kz2O2cFrTVZ6YDEkooErOXWyPdycG4yFnHpwOAIz35Y1XUo5z7wVkyWEgDxmL0/s1600/Android+SDK+Manager.PNG" height="285" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Android SDK Manager: Installing Android SDK Build-tools (Rev. 19.1)</td></tr>
</tbody></table>
<pre style="background-color: white; font-size: 12px; max-width: 80em; padding-left: 0.7em; white-space: pre-wrap;"></pre>
</div>
Anonymoushttp://www.blogger.com/profile/11965306538365617369noreply@blogger.com0tag:blogger.com,1999:blog-3223522705179095073.post-63649823408958127222014-06-12T01:41:00.006-07:002014-06-12T01:42:02.102-07:00Using Custom Fonts in Grails<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Trebuchet MS, sans-serif;">I want to include a custom font and I created a folder under <b>web-app</b> and named it 'fonts' and I copied my font to that folder. Then,</span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;">1. I added the <b>fonts</b> folder to be included as a grails resource in <b><i>Config.groovy</i></b> like:</span><br />
<br />
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQoURTYi5poNc1gleyFb1eLuzc9HaQ1fgcsOYdiDl-u7yxhlSkK9Sn3tACpAfTQjLXs9_TRlEf-ZnjUHJ3SLtfD_L1HNPKNunW-kZRJV3DM6-WgDJgO14X3XAHy-HUf7nGS6KQwnI740it/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> // What URL patterns should be processed by the resources plugin
grails.resources.adhoc.patterns = ['/images/*', '/css/*', '/js/*', '/plugins/*', <b>'/fonts/*'</b>]
grails.resources.adhoc.includes = ['/images/**', '/css/**', '/js/**', '/plugins/**', <b>'/fonts/**'</b>]
</code></pre>
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span style="font-family: Trebuchet MS, sans-serif;">2. Since I'm using Spring security plugin for grails, I added the <b>'fonts*'</b> folder to '<b>permitAll</b>' category of <b>Requestmap</b>.</span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;"> // Request map Stored in Database</span><br />
<br />
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQoURTYi5poNc1gleyFb1eLuzc9HaQ1fgcsOYdiDl-u7yxhlSkK9Sn3tACpAfTQjLXs9_TRlEf-ZnjUHJ3SLtfD_L1HNPKNunW-kZRJV3DM6-WgDJgO14X3XAHy-HUf7nGS6KQwnI740it/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> for (String url in [
'/', '/index', '/index.gsp', 'favicon.ico',
'js*', 'css*', 'images*', <b>'fonts*'</b>,
'/login', '/login*//**',
'/logout', '/logout*//**'
]) {
Requestmap.findOrSaveByUrlAndConfigAttribute(url, 'permitAll').save()
}
</code></pre>
<br /></div>
Anonymoushttp://www.blogger.com/profile/11965306538365617369noreply@blogger.com0tag:blogger.com,1999:blog-3223522705179095073.post-21036657142661929922014-06-10T06:05:00.000-07:002014-06-10T06:40:26.104-07:00Grails: Listing all fields/variables in a Domain/Model<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Trebuchet MS, sans-serif;">In this example, I assume your domain class name is 'Research' and the full package name is 'com.package.name.Research'</span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;">Way 1:</span><br />
<br />
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQoURTYi5poNc1gleyFb1eLuzc9HaQ1fgcsOYdiDl-u7yxhlSkK9Sn3tACpAfTQjLXs9_TRlEf-ZnjUHJ3SLtfD_L1HNPKNunW-kZRJV3DM6-WgDJgO14X3XAHy-HUf7nGS6KQwnI740it/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> Research.declaredFields.each{
if(!it.synthetic)
println it.name
}
</code></pre>
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;">Way 2:</span><br />
<br />
<pre style="font-family:arial;font-size:12px;border:1px dashed #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;;background-image:URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQoURTYi5poNc1gleyFb1eLuzc9HaQ1fgcsOYdiDl-u7yxhlSkK9Sn3tACpAfTQjLXs9_TRlEf-ZnjUHJ3SLtfD_L1HNPKNunW-kZRJV3DM6-WgDJgO14X3XAHy-HUf7nGS6KQwnI740it/s320/codebg.gif);padding:0px;color:#000000;text-align:left;line-height:20px;"><code style="color:#000000;word-wrap:normal;"> def names = grailsApplication.getDomainClass('com.package.name.Research').persistentProperties.collect {
println it.name
}
</code></pre>
<span style="font-family: Trebuchet MS, sans-serif;">Way 3:</span><br />
<br /></div>
<pre style="font-family:arial;font-size:12px;border:1px dashed #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;;background-image:URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQoURTYi5poNc1gleyFb1eLuzc9HaQ1fgcsOYdiDl-u7yxhlSkK9Sn3tACpAfTQjLXs9_TRlEf-ZnjUHJ3SLtfD_L1HNPKNunW-kZRJV3DM6-WgDJgO14X3XAHy-HUf7nGS6KQwnI740it/s320/codebg.gif);padding:0px;color:#000000;text-align:left;line-height:20px;"><code style="color:#000000;word-wrap:normal;"> def Research domainClass = grailsApplication.getGrailsDomainClass('Research')
def persistentProperties = domainClass.getPersistentProperties()
persisentProperties.each { property ->
println property
}
</code></pre>Anonymoushttp://www.blogger.com/profile/11965306538365617369noreply@blogger.com0tag:blogger.com,1999:blog-3223522705179095073.post-87931177490640573302014-06-05T02:38:00.001-07:002014-06-05T02:38:43.065-07:00Run Windows Command prompt (CMD) in Full screen mode<div dir="ltr" style="text-align: left;" trbidi="on">
I got this values for running Windows CMD in full screen mode. Width=237, Height=82<br />
<br />
Open CMD, Right click on the title bar and select Properties and set this values.<br />
<br />
For more info, read <a href="http://www.thewindowsclub.com/full-screen-command-prompt-in-windows-7" target="_blank">this</a>.<br />
<br /></div>
Anonymoushttp://www.blogger.com/profile/11965306538365617369noreply@blogger.com0tag:blogger.com,1999:blog-3223522705179095073.post-37369764111455249132014-06-05T01:50:00.001-07:002014-06-05T01:50:14.840-07:00Android Tips: How to (always) show Overflow in Action bar<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Verdana, sans-serif;">Here is how!</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">try {</span><br />
<span style="font-family: Courier New, Courier, monospace;"> ViewConfiguration config = ViewConfiguration.get(this);</span><br />
<span style="font-family: Courier New, Courier, monospace;"> Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");</span><br />
<span style="font-family: Courier New, Courier, monospace;"> if(menuKeyField != null) {</span><br />
<span style="font-family: Courier New, Courier, monospace;"> menuKeyField.setAccessible(true);</span><br />
<span style="font-family: Courier New, Courier, monospace;"> menuKeyField.setBoolean(config, false);</span><br />
<span style="font-family: Courier New, Courier, monospace;"> }</span><br />
<span style="font-family: Courier New, Courier, monospace;"> } catch (Exception e) {</span><br />
<span style="font-family: Courier New, Courier, monospace;"> e.printStackTrace();</span><br />
<span style="font-family: Courier New, Courier, monospace;"> }</span><br />
<span class="Apple-tab-span" style="white-space: pre;"><span style="font-family: Courier New, Courier, monospace;"> </span></span></div>
Anonymoushttp://www.blogger.com/profile/11965306538365617369noreply@blogger.com0tag:blogger.com,1999:blog-3223522705179095073.post-91379266085113322972014-06-03T01:46:00.001-07:002014-06-03T01:46:20.615-07:00Parsing and Formatting a Date in Groovy/Grails<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Trebuchet MS, sans-serif;">If you have a string variable containing a date value such as 2014-06-03T11:03:44.779+03, then:</span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;"><b>First </b>- Convert it to Date using "parse" method of SimpleDateFormat</span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><b>Seond </b>- Format the Date using the format you want such as "yyyy-MM-dd" or "yyyy/MM/dd" or any other.</span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif; font-size: large;">Code</span><br />
<br />
<span style="font-family: Courier New, Courier, monospace;">import java.text.SimpleDateFormat</span><br />
<span style="font-family: Courier New, Courier, monospace;">import java.text.DateFormat</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">String mydate = "2014-06-03T11:03:44.779+03"</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd")</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">Date parsedDate = formatter.parse(mydate)</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">Date formattedDate = formatter.format(parsedDate)</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">/* In one line</span><br />
<span style="font-family: Courier New, Courier, monospace;"> Date parsedAndFormattedDate = formatter.format(formatter.parse(mydate))</span><br />
<span style="font-family: Courier New, Courier, monospace;">*/</span></div>
Anonymoushttp://www.blogger.com/profile/11965306538365617369noreply@blogger.com0tag:blogger.com,1999:blog-3223522705179095073.post-17072289641914538012014-04-23T00:13:00.000-07:002014-06-05T02:36:26.006-07:00Android: How to call another activity when a button is pressed and close the first activity<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="background-color: white; border: 0px; clear: both; margin-bottom: 1em; padding: 0px; vertical-align: baseline;">
<span style="font-family: Arial, Liberation Sans, DejaVu Sans, sans-serif;"><span style="font-size: 14px; line-height: 18px;">Here is a complete class that shows how another activity is called when a button in the first activity is pressed.</span></span></div>
<pre class="default prettyprint prettyprinted" style="background-color: #eeeeee; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 14px; line-height: 18px; margin-bottom: 10px; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto; word-wrap: normal;"><code style="border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; margin: 0px; padding: 0px; vertical-align: baseline; white-space: inherit;"><span class="kwd" style="background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;">public</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="kwd" style="background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;">class</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">FirstActivity</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="kwd" style="background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;">extends</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">Activity</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="kwd" style="background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;">implements</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">View</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">OnClickListener</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">{</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">Button</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> goToSecondActivityButton</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">;</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="lit" style="background-color: transparent; border: 0px; color: maroon; margin: 0px; padding: 0px; vertical-align: baseline;">@Override</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="kwd" style="background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;">protected</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="kwd" style="background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;">void</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> onCreate</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">Bundle</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> savedInstanceState</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">)</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">{</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="kwd" style="background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;">super</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">onCreate</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">savedInstanceState</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">);</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">
setContentView</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">R</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">layout</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">first_activity</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">);</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">((</span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">TextView</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">)</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> findViewById</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">R</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">id</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">textRecommendationMessage</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">)).</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">setText</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="str" style="background-color: transparent; border: 0px; color: maroon; margin: 0px; padding: 0px; vertical-align: baseline;">"This is the first activity"</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">);</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">
goToSecondActivityButton</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">Button</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">)</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> findViewById</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">R</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">id</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">button_go_to_second_activity</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">);</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">
goToSecondActivityButton</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">setOnClickListener</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="kwd" style="background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;">this</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">);</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">}</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="lit" style="background-color: transparent; border: 0px; color: maroon; margin: 0px; padding: 0px; vertical-align: baseline;">@Override</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="kwd" style="background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;">public</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="kwd" style="background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;">void</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> onClick</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">View</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> view</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">)</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">{</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">
goToSecondActivity</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">();</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">}</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="kwd" style="background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;">private</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="kwd" style="background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;">void</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> goToSecondActivity</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">()</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">{</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">Intent</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> intent </span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="kwd" style="background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;">new</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">Intent</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">FirstActivity</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="kwd" style="background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;">this</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">,</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">SecondActivity</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="kwd" style="background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;">class</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">);</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">
startActivity</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">intent</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">);</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">
finish</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">();</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">}</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">}</span></code></pre>
</div>
Anonymoushttp://www.blogger.com/profile/11965306538365617369noreply@blogger.com0