If you’re developing lift in IntelliJ, often you get popup inspector errors all over your XHTML markup because the namespaces of your snippet classes, etc. are not valid. To turn it off, you can click on the inspector in the bottom right of the intelliJ window, Configure Inspections, and turn off that specific XML setting inspection in the XML options. Nothing huge, but it saves some annoyance.
This may not seem like a difficult task for many of the more experienced Scala/Lift developers out there but it took me some time to write this little piece and I thought I would share it.
I basically needed a way to redirect clients running IE6 to a single page which explained that the site does not support their browser and here is how to upgrade. To do this, I used the LiftRules object’s dispatch field inside the boot.scala file. Here’s the line of code:
LiftRules.dispatch.prepend {
case Req(path, _, _) if (path != List("unsupported-browser") && S.request.dmap(false)(_.isIE6)) => () => {Full(RedirectResponse("unsupported-browser"))}
}
So I showed this line to my co-worker, Jeff, and his eyes almost popped out of his head. I am digging Scala and Lift and I do see the power once I get a grasp on the syntax. However, ramping up in this language is no small task. It has actually been quite difficulty for me and while I may not be the sharpest developer in the world, I think I am relatively capable. Anyway, enough of a rant. Here’s what is going on above. If any Scala masters are reading this and want to correct my explanation, please feel free.
We are prepending a new rule to the dispatch field. The format of the case statement is basically case pattern if guard => {/*do something*/}
The part that I got stuck on was binding a variable in the pattern that could be used in the guard. So here’s how it breaks down.
Pattern: Req(path, _, _)
This grabs the current dispatch request and binds the path variable to the current path list.
Guard: if (path != List("unsupported-browser") && S.request.dmap(false)(_.isIE6))
The guard takes the binded path variable and checks to make sure it is any single path on the site EXCEPT the /unsupported-browser path. That is an important part since we do not want a infinite loop redirect. The second half of the guard takes the current session request box and uses dmap to open it and check if the current browser is indeed ie6.
Action: If the pattern and guard are satisfied then we do a redirect to the unsupported browser page.
Hopefully some people find this information useful.
Update: This is easier now. See this post: http://blog.morroni.com/2011/03/11/the-best-lift-sbt-intellij-startup-process/
This post describes how to get IntelliJ, Git, SBT(Scala Build Tool) and Lift playing nicely together. This post assumes you have Maven and SBT already installed since you will need them in order to make this work. More information about the sbt setup is here: http://code.google.com/p/simple-build-tool/wiki/Setup. Information about installing maven is available here: http://maven.apache.org/run-maven/index.html
Install GIT
- Browse to http://code.google.com/p/git-osx-installer/
- Install the git package.
- After installation, you need to run a shell command to finish things properly. it sets paths and what not.
- Open up a terminal.
- Change directories to the mounted image
bash$ cd /Volumes/Git\ 1.6.4.4\ Intel\ Leopard/bash$ ./setup\ git\ PATH\ for\ non-terminal\ programs.sh- Close your terminal and reopen it. Now type
gitand confirm it is installed.
Download archetype
- Open up terminal and browse to a folder where you will store your project.
- Type the following:
mvn archetype:generate -U \
-DarchetypeGroupId=net.liftweb \
-DarchetypeArtifactId=lift-archetype-basic \
-DarchetypeVersion=2.0 \
-DremoteRepositories=http://scala-tools.org/repo-releases \
-Dversion=0.1 \
-DgroupId=com.myCompany.myProject -DartifactId=myProject- Change into the folder where the project was created and type <code>sbt update</code>. this will download the libraries and crate the sbt project folder.
Open IntelliJ
I did a pretty verbose post on using IntelliJ with lift here: http://blog.morroni.com/2010/07/14/setup-intellij-9-for-lift-framework-development/. This assumes you have installed the Scala and SBT plugins in IntelliJ.
- Now we open up IntelliJ and import the maven project. File -> New Project ->Import Project From External Model.
- Let IntelliJ do its thing and when it is done, we will need to add a class describing sbt build information. Create a folder inside project/build and create a file called LiftProject.scala. Place the following inside that file.
import sbt._
class LiftProject(info: ProjectInfo) extends DefaultWebProject(info) {
val liftVersion = "2.0"override def libraryDependencies = Set(
"net.liftweb" % "lift-webkit" % liftVersion % "compile->default",
"net.liftweb" % "lift-mapper" % liftVersion % "compile->default",
"org.mortbay.jetty" % "jetty" % "6.1.22" % "test->default",
"junit" % "junit" % "4.5" % "test->default",
"org.scala-tools.testing" % "specs" % "1.6.2.1" % "test->default",
"com.h2database" % "h2" % "1.2.138"
) ++ super.libraryDependencies
} - Open up a terminal and inside your project folder type
sbt ~jetty-run - Open up your web browser and browse to http://localhost:8080
- Hopefully, you see your project. if not, it’s probably because my post was too terse. I apologize, but a lot of these posts are just so I do not forget certain processes
I am making an assumption here that you already know the normal forward-usage of the patch command. If you’re unversed In case you didn’t want to decipher the entire man page just yet, you’re in luck. I came across an instance where I had to remove a previous patch file from the Magento Enterprise code-base. The patch was originally applied as so:
patch -p0 < firstpatch.patch
Problems ensued, and I was given a new patch, however it was a cumulative patch so it couldn’t be laid over the first patch. So how to remove? After a man-page reading, it’s quite a breeze. You need the original patch to be removed, and use the patch number you used in the first patching instance. In this case it equates to the following:
patch -R -p0 < firstpatch.patch
now you can add the new patch.
patch -p0 < secondpatch.patch
Hopefully this will save someone a man-page reading on a small terminal in a dimly lit server room.
This small tutorial may seem overly simplified but I think that a lot of newbies out there will find it helpful. I also would consider using sbt instead of just maven but this tutorial covers just maven.
I have been developing using Lift for a little over a year now and I found the IDE choices grim. I tried Eclipse, Netbeans and IntelliJ. My clear favorite is IntelliJ. It does not specifically support the Lift Framework but it does have great support for Scala and Maven. Here’s how I set things up.
Download and Install Maven 2.2.1: http://maven.apache.org/download.html
You MUST set your M2_HOME environment variable and you must make sure the mvn executable is in your execution path. Methods to accomplish this vary from system to system.
Go to a directory where you want to create your Lift app and run something like this(varies depending on archetype)
1 2 3 4 5 6 7 | mvn archetype:generate -U \ -DarchetypeGroupId=net.liftweb \ -DarchetypeArtifactId=lift-archetype-basic \ -DarchetypeVersion=2.0 \ -DremoteRepositories=http://scala-tools.org/repo-releases \ -Dversion=0.1 \ -DgroupId=com.morroni.jagger -DartifactId=store-jagger |
Download and install intelliJ 9.02 Community Edition or Ultimate: http://www.jetbrains.com/idea/download/
Open up IntelliJ and goto the menu item IntelliJ->Preferences. Choose the Plugins menu on the left and click the Available tab at the top. Type “scala” to search for the relevant plugins. Highlight the Scala plugin and click the little disk/arrow icon to install them.

Open up IntelliJ and goto File->New Project
Choose Import project from external model and click Next

Enter the location of the folder where you generated your maven project and click next

Select both profile radio boxes and click Next

Make sure the only Maven project available is selected and click Next

Click Finish.
When you are ready to run your project, right click on it and select Run “store-jagger [jetty:run]”

Open up a web browser and go to http://localhost:8080

I ran into this problem and got stuck on it for a day so I thought I would post. The only way to get PHP to talk to Microsoft SQL server properly on a Redhat/Centos 5.4 build is to ensure that you have disabled SELinux at start-up. This option is available from the install menu but can also be achieved by modifying the boot parameters.
Displaying a menu item only if a user is logged in. If they are not logged in, route them to /login
This is inside Boot.scala
1 2 3 4 | val LoggedIn = If(() => User.loggedIn_?, () => RedirectResponse("/login")) val myLoc = Loc("SecurePage", "securePage" :: Nil, "Secure Page", LoggedIn) val myMenu = Menu(myLoc) val entries = myMenu ::Menu(Loc("Home", List("index"), "Home")) ::: User.sitemap |
Generate the api documents for a lift/scala project
1 | mvn scala:doc |
You may receive trouble if you receive so much email that your quota of space on the mailserver goes beyond the limits. There are a few things you can do to stop this from happening, and if it is too late, you can recover some space and your email will begin functioning properly thereafter.
First off, you can set your email client to delete the messages from your trashcan when you close the application.
If you are running Mozilla Thunderbird:
1) Go to the Tools -> Account Settings from the menu.
2) Make sure your account is expanded in the left pane and Select “Server Settings” underneath your account.
3) Make sure you have checked “Empty Trash on Exit”. Now when you close your email client, it will automatically delete your trashed items and they will no longer be taking up space on the server.
Maybe your account is locked because you are already over quota? You can use the webmail interface to get into your email and delete large old messages.
1) go to <a href=”http://morronimail.com”>morronimail.com</a> and log in using your email user id and password.
2) click on the “size” label on the far right column of your email listings. this will sort your email by size. If if is not sorted largest to smallest, click on it again to attain this sort order.
3) you can click the checkbox on the left of your older and larger emails, especially those with attachments (PDF, Images, etc) that you no longer need. Click the delete option at the the top and it will place a strike-through font to all the emails you selected. Now click the purge emails option, and they will be permanently deleted, thus freeing space up on your account.
If you will be creating a web store, you will definitely need to setup a Merchant Account and a payment gateway. When creating a merchant account, it is a good practice to start with a bank you already work with. You can certainly shop around for better rates. For a payment gateway we recommend authorize.net
What to know for your Merchant Account application process:
1) If you have started development of your e-commerce site, get your merchant account under wraps as soon as possible. It takes time to work out a deal and even get approval from a bank, and if you are shopping around for the best deal, it will take even longer.
2) Know your products, and know your sales potential. You will need to offer the banks prospective sales numbers when negotiating the terms of your merchant account.
3) Be prepared to deal with fraud. Credit fraud happens. What will your recourse be if someone uses a stolen credit card through your e-commerce site? There are certainly steps to take to head this off. New sites most likely take advantage of better security measures such as Address Verification for the cardholder, as well as confirmation of CV2 codes. (the numbers on the back of your credit card)
Payment Gateways:
Payment gateways work through a secure encrypted route of communication between your e-commerce site and credit authorization services for validating transactions. They are a necessary safeguard against credit fraud. Additionally, you can use services through a payment gateway to process repeated billing cycles. This would be an additional plus if the services you are rendering are to be charged in some recurring basis.
With a merchant account and a proper payment gateway, you will be properly equipped to enter the e-commerce realm. If you are interested in more information on our e-commerce solutions, please contact us
Method 1: Microsoft Office Outlook 2007
- Start Outlook.
- On the Tools menu, click Account Settings.
- Click New.
- Click Microsoft Exchange, POP3, IMAP, or HTTP, and then click Next.
- In the Auto Account Setup dialog box, click to select the Manually configure server settings or additional server types check box, and then click Next.
- Click Internet E-Mail, and then click Next.
- In the Server Information section, select IMAP for Account Type.
- In the Your Name box, enter your name exactly as you want it to appear to recipients.
- In the E-mail Address box, type your e-mail address, for example, jdoe@example.com
- In the User Name box, type your account name. Your account name is comprised of a “mor” prefix, and then four numbers.
- In the Password box, type your password.
- In the Incoming mail server box, type the name of your IMAP4 server, in this case “mailserver.morronimail.com”
- In the Outgoing mail server (SMTP) box, type the name of your SMTP server, in this case “smtpserver.morronimail.com”
- Click Next after you have completed entering this configuration information, and then click Finish.
Note IMAP4 is a retrieval protocol. You must have SMTP to send your messages.
Method 2: Microsoft Office Outlook 2003 and earlier versions of Outlook
- Start Outlook.
- On the Tools menu, click E-mail Accounts.
- Under E-mail Accounts, click Add a new e-mail account, and then click Next.
- Click IMAP as the type of account that you are creating, and then click Next.
- In the Your Name box, enter your name exactly as you would like it to appear to recipients.
- In the E-mail Address box, type your e-mail address., for example, jdoe@example.com
- In the User Name box, type your account name. Your account name is comprised of a “mor” prefix, and then four numbers.
- In the Password box, type your password.
- In the Incoming mail server (IMAP) box, type the name of your IMAP4 server,in this case “mailserver.morronimail.com”
- In the Outgoing mail server (SMTP) box, type the name of your SMTP server, in this case “smtpserver.morronimail.com”
- Click Next after you have completed entering this configuration information, and then click Finish.






