I was migrating angular JS from 1.3.2 to 1.8.2 and came through an error "TypeError: formctrl.$addcontrol is not a function" - html

The 1.3.2 developer has not used formctrl.$addcontroller anywhere in the code. Its onavailable in agular.js . But it thrown an error
TypeError: formctrl.$addControl is not a function at Object.ngModelPretink (angular.js:31549:20)
angular.js:15697
at angular.js:1391:18 at invokeLinkFn (angular.js:11376:9) at nodeLinkFn (angular.js:10672:11)
at compositeLinkFn (angular.js:9942:13) at compositeLinkFn (angular.js:9945:13)
at compositeLinkFn (angular.js:9945:13)
at compositeLinkFn (angular.js:9945:13)
at publicLinkFn (angular.js:9807:30) at lazycompilation (angular.js:10221:25) <textarea name="email messag
e" cols="41" rows="5" ng-model="sparent.$parent.$parent.sparent.selectedTe mplatecopy.content" aria-label."(('email.messageTitle' | translate}}" styl
e="height:140px;" class="ng-pristine ng-untouched ng-valid">"
I tried to upgrade the version of this application from v1.3.2 to 1.8.2 and its showing this error for multiple templates

Related

I am trying to do the function add one month to the current month in JSP and show the result in textbook in html

This is my input box that should show date in one month.
<div class="form-group">
<label for="datum_uplate">Datum isteka:</label>
<input type="date" class="form-control" id="datum_isteka" name="datum_isteka" >
This is my jsp code, I don't want to use javascript for security reasons.
<%
LocalDateTime.now().plusMonths(1);
int months = int.Parse("datum_isteka".toString());
LocalDateTime newDate = LocalDateTime.now().plusMonths(months);
%>
And when I launch my tomcat this is what comes up:
Type Exception Report
Message java.lang.ClassNotFoundException: org.apache.jsp.index_jsp
Description The server encountered an unexpected condition that prevented it from fulfilling the request.
Exception
org.apache.jasper.JasperException: java.lang.ClassNotFoundException: org.apache.jsp.index_jsp
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:176)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:380)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)
javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
Root Cause
java.lang.ClassNotFoundException: org.apache.jsp.index_jsp
java.net.URLClassLoader.findClass(URLClassLoader.java:381)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:129)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:60)
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:171)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:380)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)
javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
Note The full stack trace of the root cause is available in the server logs.
You are getting the error because of the below line:
int months = int.Parse("datum_isteka".toString());
The syntax that you are using will not work in Java.
If I am thinking correct, you are trying to get the input value and want evaluate in the jsp, which not possible because jsp code will executed way before you can see the html content in browser.
If you don't want use JavaScript in your code then to get the textbox value you need to submit the page like below:
<!-- here I am using post method, coz I dont want users to see the content in the browser -->
<form method="post" action="index.jsp">
<div class="form-group">
<label for="datum_uplate">Datum isteka:</label>
<input type="date" class="form-control" id="datum_isteka" name="datum_isteka" >
<input type="submit" value="Get Months">
</form>
<%
// to get the you use the java code
if (request.getParameter("datum_isteka") != null ) {
LocalDateTime.now().plusMonths(1);
//int months = int.Parse("datum_isteka".toString());
int months = Integer.parseInt(request.getParameter("datum_isteka")); // here you may need to handle empty string, `parseInt` method will throw error if the given value is empty, i.e; `datum_isteka` textbox value.
LocalDateTime newDate = LocalDateTime.now().plusMonths(months);
}
%>
Now the newDate will have the required value.

Angular 4 error formating Date field in ISO format with DatePipe

In an angular 4 / nodejs application, I am retrieving the following date field from MongoDB:
"2018-06-14T03:00:00.000Z"
Here is my HTML:
<div *ngIf="this.Lacador.dataAssociacao">
<p style="margin-top: 10px" type="text"> <label style="font-weight: normal"> {{ this.Lacador.dataAssociacao | date:"dd/MM/yyyy" }} </label></p>
</div>
In the screen, the date is displayed (as per image), but I have an error in the console which messes with all the scripts of the page:
ERROR Error: InvalidPipeArgument: 'function Date() { [native code] }' for pipe 'DatePipe'
at invalidPipeArgumentError (common.es5.js:2610)
at DatePipe.webpackJsonp.../../../common/#angular/common.es5.js.DatePipe.transform (common.es5.js:3506)
at checkAndUpdatePureExpressionInline (core.es5.js:11665)
at checkAndUpdateNodeInline (core.es5.js:12370)
at checkAndUpdateNode (core.es5.js:12303)
at debugCheckAndUpdateNode (core.es5.js:13167)
at debugCheckRenderNodeFn (core.es5.js:13146)
at Object.eval [as updateRenderer] (LacadoresViewComponent.html:96)
at Object.debugUpdateRenderer [as updateRenderer] (core.es5.js:13131)
at checkAndUpdateView (core.es5.js:12275)
Date displayed correctly:
Any clues on why it throws an exception, even through it formats the field as I want?
Edit: Added a missing quote.

Match Error with Meteor.callLoginMethod

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.

How to fix the Angular syntax parser error within a Struts 2 <s:checkbox> tag?

I have encountered a strange error using AngularJS + Struts 2.
I have a Java object form with a boolean attribute named paid.
When I write:
<div class="col-sm-10 form-checkbox">
<s:checkbox name="xxxxx" ng-model="model"
ng-init="model = <s:property value = '%{form.paid}' />"
theme="simple" />
</div>
I get FireBug complaining about AngularJS syntax parser error which directs me to this page:
syntax error page
suggesting expression error.
And if I write:
<div class="col-sm-10 form-checkbox">
<s:checkbox name="xxxxx" ng-model="model"
ng-init="%{form.paid}"
theme="simple" />
</div>
No error is reported. I guess it is because Struts tags begin with <, which is not welcomed in Angular.
But, with this line no error is reported:
<select ng-model="estadoId"
ng-init="estadoId=<s:property value='%{form.estadoId}'/>"
name="form.estadoId" id="form.estadoId"
value="<s:property value='%{form.estadoId}' />" >
So, AngularJS is complaining about <> in Struts 2? Or, I am nor permitted to use <s:...> inside another <s:...>? If the latter is the case, why is complaning Angular not Struts 2??
In the first snippet, you are nesting Struts tags, that is a syntax error:
<s:checkbox name="xxxxx"
ng-model="model"
ng-init="model = <s:property value = '%{form.paid}' />"
theme="simple" />
In the second one, you are doing it right with OGNL, but you omitted the model = part:
<s:checkbox name="xxxxx"
ng-model="model"
ng-init="%{form.paid}"
theme="simple" />
The right version is the mix of the two:
<s:checkbox name="xxxxx"
ng-model="model"
ng-init="model = %{form.paid}"
theme="simple" />
Otherwise you could use a raw HTML tag (as in your <select> example, that is a standard HTML tag and not an <s:select>, hence no tags nesting is happening):
<input type="check" name="xxxxx"
ng-model="model"
ng-init="model = %{form.paid}" />
Note: in that case, you should create an hidden parameter under each checkbox to emulate the <s:checkbox> tag behavior and make the Checkbox Interceptor happy.

KeyError: 'filename' while linking python and html using karrigell

I'm trying to read an uploaded file using python 2.7 and Karrigell. But it is showing me:
Traceback (most recent call last):
File "C:\Karrigell-3.1.1\karrigell\core\HTTP.py", line 333, in process_request
File "C:\Karrigell-3.1.1\karrigell\core\k_target.py", line 399, in run
File "", line 7, in
File "cgi.pyc", line 541, in __getitem__
KeyError: 'filename'
Here is my web_access.py:
import cgi, os
form = cgi.FieldStorage()
fileitem=form['filename']
if fileitem.file:
print fileitem.file.read()
else:
print "Error"
My Html page:
<section>
Enter the text:
<form action="web_access.py" method="post" enctype="multipart/form-data">
<input type="file" name="filename" id="file" value="" size="50"/>
<br />
<input type="submit" value="Analyze"/>
</form>
</section>
Help me out please!
With Karrigell you don't need to use the CGI module ; you get a reference to form fields as keys of the built-in object REQUEST
web_access.py could be something like
print REQUEST['filename'].file.read()
This is documented here