I am following the Play framework tutorial, and to the point opening the tasks page but it constantly returns the following error which I can't seem to fix:
[RuntimeException: java.lang.VerifyError: (class: views/html/index$$anonfun$apply$1, method: apply signature: (Lmodels/Task;)Lplay/api/templates/Html;) Expecting to find integer on stack]
Can anyone point me to where to look for an error? I've tried JDK 6 & 7 32 & 64 bit versions all to no avail.
Here is my Index.scala.html:
#(tasks: List[Task], taskForm: Form[Task])
#import helper._
#main("Todo list") {
<h1>#tasks.size() task(s)</h1>
<ul>
#for(task <- tasks) {
<li>
#task.label
#form(routes.Application.deleteTask(task.id)) {
<input type="submit" value="Delete">
}
</li>
}
</ul>
<h2>Add a new task</h2>
#form(routes.Application.newTask()) {
#inputText(taskForm("label"))
<input type="submit" value="Create">
}
}
Related
I'm trying to send my login with :
'submit form': function(event) {
event.preventDefault();
event.stopPropagation();
var loginRequest = {
username: event.target.loginUsername.value.toLowerCase(),
password: event.target.loginPassword.value,
};
var callback = function(response) {
Session.set('showLoading', false);
};
Session.set('showLoading', true);
Accounts.callLoginMethod({
methodArguments: [loginRequest],
userCallback: callback,
});
},
But I get an error and I can't figure out what is the thing that create this error :
Exception while invoking method 'login' Error: Match error: Unknown key in field username
...
Sanitized and reported to the client as: Match failed [400]
I founded some informations in the web but nothing that really helped me. I think it's generated when I call Accounts.callLoginMethod
My form looks like this:
<form>
<div class="row">
<div class="input-field col-xs-12 col-sm-8 col-md-6 col-sm-offset-2 col-md-offset-3">
<label for="loginUsername">Username</label>
<input id="loginUsername" type="text" class="form-control" disabled="{{showLoading}}" required>
<br>
<label for="loginPassword">Password</label>
<input id="loginPassword" type="password" class="form-control" disabled="{{showLoading}}" required>
</div>
</div>
<br>
{{#if showLoading}}
{{> loading}}
{{else}}
<div class="text-center">
<button type="submit" class="btn btn-primary">Login</button>
</div>
{{/if}}
</form>
Someone could help me or know what is creating this error ?
Here is my 2 cents. Accounts.callLoginMethod is technically not a documented API function and in theory could change in any future Meteor release. Since it's not documented, the errors that it returns are not well defined and could be confusing.
Since you are just doing password authentication, I would recommend you use Meteor.loginWithPassword(user, password, [callback]) instead. At least this way you have a set of API documentation to fallback on if you get errors such as this (it also returns more specific errors when something goes wrong).
Try switching and see if you still receive an error output. If so the error will be one of the below error messages and you can better debug to see what's going on.
“Unrecognized options for login request [400]” if user or password is undefined.
“Match failed [400]” if user isn’t an Object or String, or password isn’t a String.
“User not found [403]” if the email or username provided in user doesn’t belong to a registered user.
“Incorrect password [403]” if the password provided is incorrect.
“User has no password set [403]” if user doesn’t have a password.
If you encounter one of the above errors, then do console.log(username) and make sure it is a string or object with the value that you are expecting.
I'm trying to fetch and display some MongoDB documents in my Meteor app. I am trying to use the docs here as a basis for this.
The HTM I've added is this:
{{> placesLived}}
. . .
<template name="placesLived">
<table style="width:60%">
{{#each places}}
<tr>
<td>{{ts_city}}</td>
<td>{{ts_state}}</td>
<td>{{ts_yearin}}</td>
<td>{{ts_yearout}}</td>
</tr>
{{/each}}
</table>
</template>
...so that the entire .html file is now this:
<head>
<title>timeandspace</title>
</head>
<body>
<h1>A List of the Places I Have Lived</h1>
{{> addTimeSpaceForm}}
{{> placesLived}}
</body>
<template name="addTimeSpaceForm">
<form>
<label for="city">City</label>
<input type="text" name="city" id="city">
<br/>
<label for="state">State</label>
<input type="text" name="state" id="state">
<br/>
<label for="yearin">Year Arrived</label>
<input type="text" name="yearin" id="yearin">
<br/>
<label for="yearout">Year Departed</label>
<input type="text" name="yearout" id="yearout">
<br/>
<input type="submit" name="insertdocument" id="insertdocument" value="Add Place Lived">
</form>
</template>
<template name="placesLived">
<table style="width:60%">
{{#each places}}
<tr>
<td>{{ts_city}}</td>
<td>{{ts_state}}</td>
<td>{{ts_yearin}}</td>
<td>{{ts_yearout}}</td>
</tr>
{{/each}}
</table>
</template>
The Javascript I've added is this:
Template.placesLived.helpers({
places: function () {
// this helper returns a cursor of all of the documents in the collection
return TimeAndSpace.find();
}
});
...so that the entire .js file is now this:
TimeAndSpace = new Mongo.Collection('timeAndSpace');
if (Meteor.isClient) {
Template.addTimeSpaceForm.events({
'submit form': function(event){
event.preventDefault();
var city = event.target.city.value;
var state = event.target.state.value;
var yearin = event.target.yearin.value;
var yearout = event.target.yearout.value;
Meteor.call('insertLocationData', city, state, yearin, yearout);
}
});
}
if (Meteor.isServer) {
Meteor.startup(function () {
// code to run on server at startup
});
Meteor.methods({
'insertLocationData': function(city, state, yearin, yearout){
console.log('attempting to insert a record');
TimeAndSpace.insert({
ts_city: city,
ts_state: state,
ts_yearin: yearin,
ts_yearout: yearout
});
}
});
}
Template.placesLived.helpers({
places: function () {
// this helper returns a cursor of all of the documents in the collection
return TimeAndSpace.find();
}
});
My notion of what is supposed to happen here is that the "placesLived" template is added to the page, which template calls the "places" function in the js file -- which returns all the TimeAndSpace documents -- and finally the "placesLived" template loops through those returned documents, placing each field in a "td"
However, saving these changes (which restarts the Meteor app) wreaks havoc in the Meteor field: the command prompt cast the following aspersions (not to be confused with asteroids) on me:
The Meteor machine is obviously not amused. What have I fouled in my code / what needs to change?
Your helper is running on the client & server. Put an isClient around it & you'll be fine.
Anytime you get pretty purple/blue colors on the console it means something is wrong with your server. When it says Template is not defined that tells you the server can't find something called Template.
I'm trying to make a simple angular app which reads json data , but in response I'm only getting "," not data.Any pointers where I m going wrong ? I have attached index.html and abc.json file that i m keepingat server
PFB the code .
HTML:
<body ng-app="sampleApp" ng-controller="ctrl1">
Name:<input type="text" ng-model="name">
<ul>
<li ng-repeat="student in students | filter:name">{{student.name +","+student.empNo}</li>
</ul>
Name:<input type="text" ng-model="newname">
EmpNo:<input type="text" ng-model="newemp">
<input type="button" value="AddMe" ng-click="add()"/>
<div>
<div ng-view></div>
</div>
Javascript:
var x=angular.module('sampleApp',[])
.factory("simpleFactory",function($http){
var factory={};
factory.getStudents=function(){
return $http.get("abc.json");
}
return factory;
})
.controller("ctrl1",function($scope,simpleFactory){
$scope.students=simpleFactory.getStudents();
$scope.add=function(){
$scope.students.push(
{
name:$scope.newname,empNo:$scope.newemp
}
)
}
})
abc.json
[
{"name":"jack","empNo":"1"},
{"name":"Red","empNo":"2"},
{"name":"Jill","empNo":"3"}
]
getStudents is asynchronous. You should retrieve and assign students through the callback handler.
.factory("simpleFactory",function($http){
var factory={};
factory.getStudents = $http.get("abc.json");
return factory;
})
.controller("ctrl1",function($scope,simpleFactory){
simpleFactory.getStudents().then(function(result) {
$scope.students= result.data;
});
...
})
Nearly right. getStudents in fact returns you a 'Promise', not the data itself. You have to use that Promise to get your data:
simpleFactory.getStudents().then(function(data) {
$scope.students=data
// $scope.students=data.data // you may need this given your feedback
});
I need a help about ZK framework. This is my situation.
I have a html page:
<form id="frm1" action="http://localhost:8080/spuWebApp" METHOD="POST">
<input type="hidden" id="codigoUnicoCliente" name="codigoUnicoCliente" value="00000050055255">
<input type="button" onclick="myFunction()" value="Invar Spu POST URL">
</form>
Then, after submitting the form, my zk project recieves the data in bridge.zul.
<?init class="com.ibm.ibk.spu.view.BridgeChecker"?>
This class contains the following
public class BridgeChecker extends BaseWindow implements Initiator{
#Override
public void doInit(Page arg0, Map<String, Object> arg1) throws Exception {
Bridge bridge = new Bridge();
logger.debug("ANTIGUA MANERA");
logger.debug(Executions.getCurrent().getParameterMap());
logger.debug(Executions.getCurrent().getArg());
logger.debug(Executions.getCurrent().getAttributes());
bridge.setClienteCodigoUnicoFromURL(Executions.getCurrent().getParameter("codigoUnicoCliente"));
But I cant read the value.
I am racking my brain a lot. But I couldnt succeed in find out how to read the values. Someone who can help me to read the form-data. I'd appreciate it a lot.
Thanks in advanced.
it work with Executions.getCurrent().getParameter("codigoUnicoCliente") but I do not know what myFunction() do, so I replace it with this code:
<form id="frm1" action="test.zul" METHOD="POST">
<input type="hidden" id="codigoUnicoCliente" name="codigoUnicoCliente" value="00000050055255">
<input type="submit" value="Invar Spu POST URL">
</form>
Then, I use following in test.zul
<window apply="org.zkoss.bind.BindComposer" viewModel="#id('vm') #init('test.vm.TestViewModel')">
and then in TestViewModel
#Init
public void init(#ContextParam(ContextType.SESSION) Session session) {
System.out.println(Executions.getCurrent().getParameter("codigoUnicoCliente"));
}
and work like charm :)
I have a web aplication , in which i have to specify a new css file to this section :
<section id="loginForm" >
<h2>Connecter à notre application</h2>
#using (Html.BeginForm(new { ReturnUrl = ViewBag.ReturnUrl })) {
#Html.AntiForgeryToken()
#Html.ValidationSummary(true)
<fieldset>
<legend>Formulaire de connexion</legend>
<ol>
<li>
#Html.Label("Name")
#Html.TextBox("Name")
</li>
<li>
#Html.Label("Password")
#Html.Password("Password")
</li>
</ol>
<input type="submit" value="Se connecter" />
</fieldset>
}
</section>
For example , the hole View is associated with the css file X and i'd like to associate another Y css file only for this section.
How can i do this?
Scoped CSS is coming, but the support isn't very good yet. Read more here: http://css-tricks.com/saving-the-day-with-scoped-css/ and http://html5doctor.com/the-scoped-attribute/#link
In the meantime, an alternative is to prefix all your selectors in your Y css file with #loginForm. With a preprocessor like SASS or LESS, this is very easy (wrap the file contents once), but becomes very tedious in plain CSS.