I am new to wicket and trying to get some things working.
One thing that annoys me a lot is that I get a blank (0 chars of text) page whenever there is a syntax error on a page.
Striped down example:
Test.html
header stuff: doctype ... html ... head ... body ...
<span wicket:id="msgTest" id="message">MSG</span>
footer stuff: /body ... /html
Test.java
public class Test extends WebPage {
public Test() {
add(new Label("msgTest", "Hello, World!"));
}
}
This will output the page as expected.
Now, lets introduce an error:
header stuff: doctype ... html ... head ... body ...
<span wicket:id="msgTest2" id="message">MSG</span>
footer stuff: /body ... /html
I changed the label-id to something different then what the source-file expects.
If I run this code I get the already mentioned blank page.
However, for every request to a page with such a syntax error I get an error report in the log-file of around 1000+ lines. This error-report is basically just wicket-generated html of a page which describes the error.
This makes me wonder why wicket isn't displaying the error-stuff instead of the blank page. I'm not very experienced with wicket but to me it somehow looks like wicket is having trouble rendering its own error-page code.
It would be nice to know how one goes about finding syntax-errors with wicket.
Reading through a 1000+ line error-report for a small error like a misplaced character seems a bit tedious.
Thanks in advance for guiding me into the right direction :)
PS:
wicket-version: 1.4.9
stage: development
I can not confirm that behavior. I went to http://wicket.apache.org/quickstart.html and created a quickstart. Changed the wicket id from 'message' to 'message1' and got a nice descriptive page in jetty:
WicketMessage: Unable to find component with id 'message' in [Page class = com.mycompany.HomePage, id = 0, version = 0]. This means that you declared wicket:id=message in your markup, but that you either did not add the component to your page at all, or that the hierarchy does not match.
How did you create your project?
What I like to do is write unit tests with WicketTester to at least verify that things render, and usually also write assertions to check the components. Something along the lines of
#Test
public void testMessageLabel(
WicketTester tester = new WicketTester();
tester.startPage(Test.class);
tester.assertLastRenderedPage(Test.class);
tester.assertComponent("msgTest", Label.class);
tester.assertLabel("msgTest", "Hello, World!");
)
Then if as in your example the code contains "msgTest" and the html contains "msgTest2" you at least get a test failure instead of seeing it as part of a failing app after deploy.
It's certainly not a complete solution, since this error will make any rendering test for the page fail and the particular failure will just give a long error message in the test result, but at least you don't have to search log files.
Related
I work with JBehave on a daily basis, but have been tasked with working on a project that uses Cucumber. In order to add a custom reporting class functionality to that project, I need to add two steps, one at the start of the feature (story) and another at the start of the scenario. I merely want to pass to the application a description of the feature/story and the scenario to be passed to the reporting module. I know that cucumber can access the scenario name through code, but that would only resolve one of the two lines - I would still need to have another one that passes the description of the feature/story.
What I've tried in the feature file:
Feature: Ecolab BDD Test Automation Demo
Scenario Outline: User can login and logout from the landing page
Given story "EcolabWebDemo_TestCases - Ecolab BDD Test Automation Demo"
Given scenario "User can login and logout from the landing page"
Given I am on the Ecolab landing page
The corresponding code for the two added Given statements at the beginning above:
#Given("^story {string}$") // \"(\\S+)\"
public void givenStory(String storyName) {
test.initStory(storyName); // will show on report in Features column
}
#Given("^scenario {string}$") // \"(\\S+)\"
public void givenScenario(String scenarioName) {
test.initScenario(scenarioName);
}
The commented regex patterns afterwards are the suggested ones I should try but do not seem to work either.
The current configuration at least seems to "find" the steps but reports:
cucumber.runtime.CucumberException:
java.util.regex.PatternSyntaxException: Illegal repetition near index
13 ^the scenario {string}$
So that's obviously not the solution. The regex used instead of {string} simply does not find a match and does not run.
regex is absolute Greek to me, not sure why it can't just be simple like the {string} option implied it would be in the cucumber documentation. I've been searching on-line for guidance for the better part of two days to no avail, I'm apparently not even sure what to be searching for.
Based on Grasshopper's suggestion, I updated the version of Cucumber from 1.2.0 to 1.2.5. I was prepared to change the pom.xml to use the 3.x versions but tried the latest of the specified libraries first, and it did report after an attempted run what the correct regex should be for the two steps I added.
#Given("^story \"([^\"]*)\"$")
and
#Given("^scenario \"([^\"]*)\"$")
Now that the project has a version that seems to recognize strings and also reports the missing steps, the project now runs as intended.
Thanks for your help, Grasshopper.
I'm attempting to do a reverse lookup on a route I've created.
The route is defined as such in my routes file:
POST /login controllers.Web.Application.authenticate
However, when I try to do a reverse on it in a form I made, I can't seem to find it. I'm attempting to do a reverse like this:
#helper.form(action = routes.login())) {
rest of the form here...
}
However, the login appears in red in intellij and when attempting to run the program, I get the following error:
play.sbt.PlayExceptions$CompilationException: Compilation error[value login is not a member of object controllers.routes]
I've attempted recompiling the project multiple times and looking around the docs, but it's just not working... Any ideas?
So, an interesting thing happened recently and I found a way to point to the original structure properly. To do so, rather than writing:
routes.Web.Application.authenticate()
As Tyler suggested, I was supposed to write:
Web.routes.Application.authenticate()
Which is totally counter-intuitive and all, but that allows me to use the original package structure.
Edit:
As we discovered in the comments, the reverse router doesn't seem to like sub packages. You should remove the Web part of your package, and move everything up a level, then change the code to be this:
#helper.form(action = routes.Application.authenticate())) {
rest of the form here...
}
Original answer:
You need to refer to the controller function, and not the name of the route, so it should look something like this:
#helper.form(action = routes.Web.Application.authenticate())) {
rest of the form here...
}
Hi i am trying for Test suite pages in Fitnesse.so my page is look like below if i hit suite button it have to suite all link and want to produce result .if i run a paritcular page its working good with Test Page .How suite page works ??
my question is whether we have to create java class for suite page or it automatically import our package in setup it will suite page i read through page but i cant get idea kindly help on this http://www.fitnesse.org/FitNesse.SuiteAcceptanceTests
http://stackoverflow.com/questions/10684735/how-to-include-all-ancestral-setup-pages-in-fitnesse-subwikis
which SuiteAcceptanceTests i have to use??? for my scenario
what I understood is In Setup we have to import our package it wil take care depanding on Folder.
My package is com.xx.xx
Apple
a
b
c
Ball
a
b
c
.....etc
Am Getting Error Like this
Test Summaries
org.apache.velocity.exception.MethodInvocationException: Invocation of method 'execute' in class fitnesse.responders.run.TestResponder$TestExecutor threw exception java.lang.StackOverflowError at suitePage.vm[line 23, column 15]
org.apache.velocity.runtime.parser.node.ASTMethod.handleInvocationException(ASTMethod.java:261)
org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:187)
org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:280)
org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:369)
org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:342)
org.apache.velocity.runtime.directive.Parse.render(Parse.java:260) org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:207)
org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:342)
org.apache.velocity.Template.merge(Template.java:356)
org.apache.velocity.Template.merge(Template.java:260)
fitnesse.html.template.HtmlPage.render(HtmlPage.java:80)
fitnesse.responders.run.TestResponder.doSending(TestResponder.java:69)
fitnesse.responders.ChunkingResponder.startSending(ChunkingResponder.java:66)
fitnesse.http.ChunkedResponse.sendTo(ChunkedResponse.java:25)
fitnesse.FitNesseExpediter.sendResponse(FitNesseExpediter.java:94)
fitnesse.FitNesseExpediter.start(FitNesseExpediter.java:46)
fitnesse.FitNesseServer.serve(FitNesseServer.java:24)
fitnesse.FitNesseServer.serve(FitNesseServer.java:17)
fitnesse.socketservice.SocketService$ServerRunner.run(SocketService.java:99)
java.lang.Thread.run(Thread.java:745)
From the exception stack trace, it looks pretty similar to the Github discussion here.
A page that includes itself, for example, in the content.txt of page .SuitePage.TestPage, you have
!include .SuitePage.TestPage
This can cause the StackOverflowError you see. Check your !includes carefully and see whether it fixes your problem.
I have a JSP that takes an Arraylist from the session object and removes the items from it. It seemed to be working fine and then out of nowhere when I navigate to that page, the page is blank. I checked the Tomcat log files and in catalina.out I am receiving a JasperException an it is showing it as being on a line with the following
for(int i; i < agentItems.size(); i++)
agentItems is the name of the ArrayList I am using. I have been debugging it and can't seem to figure out what the problem might be. I have read that a JasperException is sometiems thrown as a JSP's NullPointerException. Is this true or am I just completely overlooking the problem?
I have the web application running on a local machine and a intermediate server for development in which both of them have had no trouble. Why could it be that only on this server it is giving me problems?
That can be everything. You need to look a bit further in the stacktrace, peek to the caused by or root cause part and the trace which comes thereafter. It can be caused by many things. The JSP basically get compiled into one large try block and any catched Throwable will be wrapped into a servletcontainer specific exception like JasperException in Tomcat and clones. It boils down to this:
try {
// All translated JSP code comes here. Max 64K.
} catch (Throwable t) {
throw new JasperException(t);
}
Check the .java filename in the 1st line of the stacktrace, locate this in the work directory of the servletcontainer and open the file in an editor. Do you see it?
That said, using scriptlets is a bad practice. Use Servlets to control/preprocess/postprocess requests, use Javabeans to represent data models, use Taglibs in JSP to control the page flow and output, use Expression Language (EL) in JSP to access backend data. In your specific case, you can loop over an array or List using JSTL's c:forEach tag.
<c:forEach items="${agents}" var="agent">
<p>Agent: ${agent.name}
</c:forEach>
jasperexception can also occur when JSP is not able to access an element or item it's obtaining from outside and here it maybe is unable to access agentItems. Try to provide fully qualified class name or import the package otherwise.
I am using Struts 2.1.8 and facing validation problem in IE. I am getting the following error
An exception occurred: Error. Error message: Invalid argument.
I tried out to figure out the cause and found the following. My generated javascript code is:
field = form.elements['district.name'];
var error = "Enter only alphabets for district";
if (continueValidation && field.value != null && !field.value.match("^[a-zA-Z ]*$")) {
addError(field, error);
errors = true;
}
I tried to mock up by putting the same code in a function and calling it in onclick event. The method addError() throws the exception and the reason is field variable. If I change it to field[0], it works fine. How to fix this error?
Check the generated HTML source. Open the page in webbrowser, rightclick and choose View Source. Is the input field's name really district.name? Isn't it prefixed/suffixed with some other autogenerated key (possibly the ID/name of the <form>) like as many other MVC frameworks do? If so, you'll need to change the JavaScript code accordingly that it uses the right element name as it appears in the HTML DOM tree. You know, JavaScript runs at the client machine and only sees the generated HTML DOM tree, not the "original" server-side code which is responsible for generating the HTML.