Thursday, 3 October 2013

403 Forbidden Error on Spring Ajax GET Request

403 Forbidden Error on Spring Ajax GET Request

Well basically just trying to implement some ajax into my spring web
application. For testing purposes I have tried writing some code just to
retrieve 'user' information based on their personal 'id' values when they
press a link/button. I am assuming that it is a Server side error, that
something is wrong with my controller, although I am not entirely sure and
need help getting this to work. This is my current JSP page just for
testing:
<c:forEach var="user" items="${users}">
<tr>
<td><c:out value="${user.id}" /></td>
<td><c:out value="${user.name}"/></td>
<td><c:out value="${user.username}"/></td>
<td><c:out value="${user.email}"/></td>
<td><c:out value="${user.dob}"/></td>
<td><c:out value="${user.authority}"/></td>
<td>
<a class="update" href="<c:url value="/viewUser"><c:param
name="id"
value="${user.id}"/></c:url>"><button>Update</button></a>
</td>
<td>
<a class="delete" href="<c:url
value="/deleteUser"><c:param name="id"
value="${user.id}"/></c:url>"><button>Delete</button></a>
</td>
<td>
<a class="ajax" href="<c:url value="/ajax"><c:param
name="id" value="${user.id}"/></c:url>">Ajax</a>
</td>
</tr>
</c:forEach>
</table>
<script type="text/javascript">
$(document).ready(function(){
$('.ajax').click(function(e){
e.preventDefault();
$.ajax({
url:"http://localhost:8080/SDP_v1.7/ajax",
type: 'GET',
dataType:'json',
contentType: 'application/json',
mimeType: 'application/json',
succes: function(user){
alert(user.id + " + " + user.username);
},
error:function(user,status,er) {
alert("error: "+user+" status: "+status+" er:"+er);
}
});
});
});
</script>
This is my Controller class:
@RequestMapping("/viewUser")
public String updateUser(Model model, @RequestParam(value = "id", required
= false) Integer id) {
User user = usersService.getUser(id);
model.addAttribute("user", user);
return "settings";
}
@RequestMapping(value = "/ajax", method = RequestMethod.GET)
public @ResponseBody User getUser(@PathVariable Integer id) {
return usersService.getUser(id);
}
Essentially, I aiming to loading each user's information into a pop-up
modal with a form. Although I have to get this step working first. Thanks

Wednesday, 2 October 2013

Mustache with arrays, exception for the last item

Mustache with arrays, exception for the last item

var template = "multi: ";
//need => multi: option1; option2; option3 (no semicolon and space at the
end)
var json = {
"answerVOs": [
{ "answer" : "option 1"
},
{ "answer" : "option 2"
},
{ "answer" : "option 3"
}
]
};
document.getElementById("answers").innerHTML = Mustache.to_html(template,
json);
http://jsfiddle.net/casadev/GEbe8/1/
I need the last item in the array to be displayed without the semicolon
and space, any ideas.

JSF : downgrading JSF

JSF : downgrading JSF

I'm a JSF beginner, but I am already in a project where I have to use the
latest Web Logic Server (Oracle). What I have known is that even the
latest Web Logic Server doesn't support JSF 2.2, so I want to downgrade my
JSF to 2.1.
I'm currently using Netbeans, and tried the following
Changed the faces-config.xml's faces-config tag content from 2.2 to 2.1 2.2
<faces-config version="2.2"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/javaee/web-facesconfig_2_2.xsd">
2.1
<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_2_1.xsd"
version="2.1">
Added the dependencies such as jsf-api, jsf-impl (group id :
com.sun.faces) version 2.1.xx (I tried to use the latest) using Maven.
But after I call facesContext.getPackage().getImplementationVersion(),
which is a method to get the current JSF version, it only shows 2.2.0 as
the result, which means I haven't been able to downgrade the JSF.
Oh yeah, I'm currently using Java EE 7, which I don't want to downgrade,
so if it's possible, I would like to downgrade only the JSF while
maintaining the Java EE to the current version (7.0).

How to produce lighter mongodb c++ driver

How to produce lighter mongodb c++ driver

I'm compiling mongoclient with MSVC 2012 and boost 1.54 and the generated
lib size is about 117 mb ! I am doing something wrong ?
I'm using this command:
scons --extrapath=c:\dev\boost_1_54_0 --release --32 mongoclient

Tuesday, 1 October 2013

Invalid block tag: 'render_placeholder'

Invalid block tag: 'render_placeholder'

I'm trying to render a placeholder in my template, that I've put into a
custom CMS plugin. The problem is it's telling me that the
'render_placeholder tag is an invalid block tag.
Here's the template with the 'render_placeholder' tag.
{% extends 'base.html' %}
{% block base_content %}
<h2>Posts</h2>
{% if posts %}
{% for post in posts %}
<div class="entry-list">
{{ post.posted|date:"M d" }}
<h3><a href="{{ post.get_absolute_url }}">{{ post.title }}</a></h3>
{% render_placeholder post.body %}
<a href="{{ post.get_absolute_url }}">Read More</a>
</div>
{% endfor %}
{% else %}
<p>There are no posts.</p>
{% endif %}
{% endblock %}
Here's the base template showing the '{% load placeholder_tags %}'.
{% load placeholder_tags cms_tags sekizai_tags static menu_tags %}
<html>
<head>
{% render_block "css" %}
<link href="{{ STATIC_URL }}css/styles.css" rel="stylesheet">
</head>
<body>
{% show_menu 0 100 100 100 %}
{% cms_toolbar %}
{% placeholder base_content %}
{% block base_content %}{% endblock %}
{% render_block "js" %}
</body>
</html>
It keeps telling me "Invalid block tag: 'render_placeholder', expected
'empty' or 'endfor'".
Am I missing something stupid?
Thanks in advance.

Copying code from one project to another

Copying code from one project to another

I am having an issue where I am copying code from one project to another,
completely separate projects.
The code still shows as being linked to the previous storyboard's file
somehow.

Is there anyway to remove these links? Without re-creating all the code
manually

Using "$\cdot$" as variable placeholder – math.stackexchange.com

Using "$\cdot$" as variable placeholder – math.stackexchange.com

I've occasionally come across the use of "$\cdot$" as placeholder for a
variable, most recently in a paper on radial basis functions, which were
defined as $$ s(\cdot) = p(\cdot) + \sum_{i=1}^N ...