As a test project to try out scala I've installed Play framework with the Scala module, following the instructions provided here:
http://scala.playframework.org/
The project gets created fine, but when I go to the home url I get a warning saying the server cannot find the default controller. I've not modified anything from the default install at this point, so my controller looks like this:
package controllers
import play._
import play.mvc._
object Application extends Controller {
def index = Template
}
Any ideas on what am I missing?
Controllers are called action generators. By default the template name will be resolved from the action method name. So if the controllers.Application.index method returns a Template, the app/views/Application/index.html template will be rendered.
Also try cleaning up and re-running the app, sometime it escapes the file updates.
Have a look here http://www.playframework.org/modules/scala-0.9/controllers
Related
I am beginner to play scala framework. And I have created simple CRUD operation using it.
In my routes file I have declared all the necesary urls for different actions.
I want to know if user input some wrong url path from browser How should I display error page in play scala? Right now I am getting all the routes which are already defined.
I just found a solution for it
https://www.playframework.com/documentation/2.8.x/ScalaErrorHandling
this is the latest play scala documentation which handles such type of condition.
Since I am using runtime dependency injection (e.g. Guice), the error handler can be dynamically loaded at runtime.
The simplest way is to create a class in the root package called ErrorHandler that implements HttpErrorHandler.
If you place your error handler in the root package (i.e. package-less) and name it ErrorHandler, Play will use it by default.
But, in case you want to:
Add it inside a package;
Configure different error handlers for different environments;
Then add in application.conf the configuration property play.http.errorHandler pointing to your custom error handler class:
play.http.errorHandler = "com.example.ErrorHandler"
I want to create new companent in ATG. And if I forward to Browser Companent page, then I have 404 error. How I can fix this?
I assume that you have created a new component by creating a .properties file. The things to look for are
Is the file in an appropriate config layer? i.e. is it in a location on the configpath, such as the config directory of a module, or the localconfig directory of a server, where the application expects to look for .properties files?
Is the file a valid .properties file and properly formatted?
Is the class mentioned in the $class property correct, valid and fully qualified (package name and class name)
Has the named class been compiled successfully?
Is the named class available on the classpath? i.e. is it in the classes.jar of a module or in the classes directory (if that is how the module's class path has been defined?
Is the class a valid JavaBean - particularly, does it have a no-argument constructor?
Have you compiled, built and assembled your ATG application since creating this new component?
Have you restarted your ATG application since creating this new component?
Assuming this is all correct and yet you still cannot see your component, the next step is to troubleshoot why it is not visible.
Is the path to your component you are using in the dyn/admin component browser correct?
If the path is correct, and you still see an error in the browser, then take a look at the server logs (for around the time you first tried to access the component) - you might see an error or a sequence of errors telling you why the server could not instantiate the component
Can you go to the containing folder and see if the component is listed there - though it is OK if you cannot because it may not have been started if nothing is referencing it
Can you see your component in the ACC. Start the ACC, and go to View Components by Path and navigate to were you think your component should be. Can you see it there? If so, it means that your properties file is OK.
In the ACC, When you click on the puzzle-piece icon that represents your component, does it show it as being an instance of your class or as an instance of Object. If Object, it means that it cannot determine the class of the component
In the ACC, double-click the component and try to start it. Keep looking at the server logs as you do so
This should help you get to the bottom of things.
I have gotten all the latest jars installed for the Wicket 6.15. I can verify this in the Maven Dependencies directory.
For some reason, I feel it is still pointing to an older version of Wicket. I am getting strange errors with the add method from the MarkupContainer.
Using the quick-start example, in the HomePage class I am getting an error with:
add(new Label("message", "If you see this message wicket is properly configured and running"));
The error is:
The method add(Component[]) in the type MarkupContainer is not applicable for the arguments (Label)
Not sure why it is using Component[] as a argument and not Component... childs
as I am used to.
I am using Eclipse.
Check your import statements. You probably accidentally imported a different Label instead of org.apache.wicket.markup.html.basic.Label.
i've added a plugin called Image tool plugin for image resizeing... but when i called an instance of it
def imageTool = new ImageTool()
it gives me compilation error cause it can't resolve ImageTool class . i've tried to put import
import org.grails.plugins.imagetools.ImageTool
as a suggestion from a site .. but it didn't work .. so what is the real path to the imageTool so i can import it?? any help please:)
You can't access a class from the default package in a class that's in a package, and ImageTool is in the default package. The easiest thing to do is move that class into a subfolder, e.g. src/imagetool and add "package imagetool" to the source. You'll need to do this for each developer.
The plugin has moved to http://github.com/ricardojmendez/grails-imagetools/ and this has been fixed in that code, but I don't know if they have done a new release.
I downloaded the latest version of Zend framework, added a controller and I
can not get it to load.. Here is what I did:
C:\zend\Apache2\htdocs>zf create project myproject
Creating project at C:/zend/Apache2/htdocs/myproject
Note: This command created a web project, for more information setting up your V
HOST, please see docs/README
C:\zend\Apache2\htdocs>cd myproject
C:\zend\Apache2\htdocs\myproject>zf create controller mycontroller
Note: The canonical controller name that is used with other providers is "Mycont
roller"; not "mycontroller" as supplied
Creating a controller at C:\zend\Apache2\htdocs\myproject/application/controller
s/MycontrollerController.php
Creating an index action method in controller Mycontroller
Creating a view script for the index action method at C:\zend\Apache2\htdocs\myp
roject/application/views/scripts/mycontroller/index.phtml
Creating a controller test file at C:\zend\Apache2\htdocs\myproject/tests/applic
ation/controllers/MycontrollerControllerTest.php
Updating project profile 'C:\zend\Apache2\htdocs\myproject/.zfproject.xml'
C:\zend\Apache2\htdocs\myproject>
Then I tried to hit the controller from the browser..
http://localhost/myproject/public/mycontroller/
and I get the error: Not Found
The requested URL /myproject/public/mycontroller/ was not found on this server.
I have no idea how to resolve this, and I'm sort of shocked I'm having problems
with the Zend Server.
Dooh.. Actually the problem was quite simple.. I forgot the mod_rewrite.. Strange Zend didn't turn it on by default.
Check out the Zend Quick Start. It looks like you don't have the document root setup properly. Your request should have been http://localhost/myproject/mycontroller or http://myproject/mycontroller - if setup properly.