I have a html page where I use jQuery to load page content from a spring boot application
here is the project structure
I m using zuul as proxy I m confident about the Zuul Eureka configuration on my project
When I try to access my root project page (facturation.html) by calling in browser for localhost:9999/facturation I'm getting the following exception
org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "root folder where all thymeleaf files/facturation.html")
Caused by: java.io.FileNotFoundException: ClassLoader resource "root folder where all thymeleaf files/facturation.html" could not be resolved
at org.thymeleaf.templateresource.ClassLoaderTemplateResource.reader(ClassLoaderTemplateResource.java:130) ~[thymeleaf-3.0.6.RELEASE.jar:3.0.6.RELEASE]
at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parse(AbstractMarkupTemplateParser.java:223) ~[thymeleaf-3.0.6.RELEASE.jar:3.0.6.RELEASE]
java.io.FileNotFoundException: ClassLoader resource "root folder where all thymeleaf files/facturation.html" could not be resolved
My spring controller is as below
#Controller
public class LandingController {
private static final Logger log = LoggerFactory.getLogger(LandingController.class);
#Autowired
private AppClientFeign appClientFeign;
#Autowired
private UserClientFeign userClientFeign;
#RequestMapping("/")
String home(Model model,Principal principal) {
List<Menu> appMenus = appClientFeign.getAppMenus("facturation");
model.addAttribute("applications", appClientFeign.getApps());
model.addAttribute("applicationsHistory", appClientFeign.getAppsHistory(principal.getName()));
model.addAttribute("currentUser", userClientFeign.getUserDetails(principal.getName()));
if(log.isDebugEnabled()) {
StringBuilder stringBuilder2 = new StringBuilder();
stringBuilder2.append(appMenus);
stringBuilder2.append("");
log.debug(stringBuilder2.toString());
}
model.addAttribute("menuV", appMenus);
model.addAttribute("addClientObject", AddClientDTO.builder().build());
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(" hello world ****************** ---------------------- ************************ \n \n \n");
stringBuilder.append(appClientFeign.getApps());
if(log.isDebugEnabled())log.debug(stringBuilder.toString());
return "facturation";
}
#RequestMapping("/html/{page}")
String resolveHTML(Model model,Principal principal,#PathVariable String page) {
List<Menu> appMenus = appClientFeign.getAppMenus("facturation");
model.addAttribute("applications", appClientFeign.getApps());
model.addAttribute("applicationsHistory", appClientFeign.getAppsHistory(principal.getName()));
model.addAttribute("currentUser", userClientFeign.getUserDetails(principal.getName()));
if(log.isDebugEnabled()) {
StringBuilder stringBuilder2 = new StringBuilder();
stringBuilder2.append(appMenus);
stringBuilder2.append("");
log.debug(stringBuilder2.toString());
}
model.addAttribute("menuV", appMenus);
model.addAttribute("addClientObject", AddClientDTO.builder().build());
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(" hello world ****************** ---------------------- ************************ \n \n \n");
stringBuilder.append(appClientFeign.getApps());
if(log.isDebugEnabled())log.debug(stringBuilder.toString());
return page;
}
#RequestMapping("/html/{folder}/{page}")
String resolveHTML(Model model,Principal principal,#PathVariable String page,#PathVariable String folder) {
List<Menu> appMenus = appClientFeign.getAppMenus("facturation");
model.addAttribute("applications", appClientFeign.getApps());
model.addAttribute("applicationsHistory", appClientFeign.getAppsHistory(principal.getName()));
model.addAttribute("currentUser", userClientFeign.getUserDetails(principal.getName()));
if(log.isDebugEnabled()) {
StringBuilder stringBuilder2 = new StringBuilder();
stringBuilder2.append(appMenus);
stringBuilder2.append("");
log.debug(stringBuilder2.toString());
}
model.addAttribute("menuV", appMenus);
model.addAttribute("addClientObject", AddClientDTO.builder().build());
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(" hello world ****************** ---------------------- ************************ \n \n \n");
stringBuilder.append(appClientFeign.getApps());
if(log.isDebugEnabled())log.debug(stringBuilder.toString());
return folder+"/"+page;
}
}
My facturation.htl page is
<!DOCTYPE HTML>
<html lang="fr">
<head>
<meta charset="UTF-8"/>
<title>Facturation - MDS</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="http://localhost:9999/MDS-WEB-RESSOURCE/js/loader.js"></script>
<script src="http://localhost:9999/MDS-WEB-RESSOURCE/js/main.js"></script>
<script src="http://localhost:9999/MDS-WEB-RESSOURCE/js/facturation.js"></script>
<script src="http://localhost:9999/MDS-WEB-RESSOURCE/js/chart.js"></script>
<script src="http://localhost:9999/MDS-WEB-RESSOURCE/js/menus.js"></script>
<script src="http://localhost:9999/MDS-WEB-RESSOURCE/js/grid.js"></script>
<script src="http://localhost:9999/MDS-WEB-RESSOURCE/js/tab.js"></script>
<script src="http://localhost:9999/MDS-WEB-RESSOURCE/js/notify.js"></script>
<script src="http://localhost:9999/MDS-WEB-RESSOURCE/js/print.js"></script>
<script src="http://localhost:9999/MDS-WEB-RESSOURCE/js/check.js"></script>
<script onloadstart="loadAdditionalData()" src="http://localhost:9999/MDS-WEB-RESSOURCE/js/facturationLoader.js"></script>
<link rel="stylesheet" type="text/css" href="http://localhost:9999/MDS-WEB-RESSOURCE/css/main.css"/>
<link rel="stylesheet" type="text/css" href="http://localhost:9999/MDS-WEB-RESSOURCE/css/facturation.css"/>
<link rel="stylesheet" type="text/css" href="http://localhost:9999/MDS-WEB-RESSOURCE/css/chart.css"/>
<link rel="stylesheet" type="text/css" href="http://localhost:9999/MDS-WEB-RESSOURCE/css/grid.css"/>
<link rel="stylesheet" type="text/css" href="http://localhost:9999/MDS-WEB-RESSOURCE/css/tab.css"/>
<link rel="stylesheet" type="text/css" href="http://localhost:9999/MDS-WEB-RESSOURCE/css/notify.css"/>
<link rel="stylesheet" type="text/css" href="http://localhost:9999/MDS-WEB-RESSOURCE/css/menus.css"/>
<link rel="stylesheet" type="text/css" href="http://localhost:9999/MDS-WEB-RESSOURCE/css/dropdown.css"/>
<link rel="stylesheet" type="text/css" href="http://localhost:9999/MDS-WEB-RESSOURCE/css/check.css"/>
</head>
<body>
<div id="overlay" class="overlay">
<div class="form-container">
</div>
</div>
<div style="height: 100%;">
<div id="header" class="header">
</div>
<div id="menu0" class="menu-V">
</div>
<div class="container">
<div id="menu0-func0-panel" class="main-panel" style="display: block;">
</div>
<div id="menu0-func1-panel" class="main-panel">
</div>
<div id="menu0-func2-panel" class="main-panel">
</div>
<div id="menu0-func3-panel" class="main-panel">
</div>
</div>
</div>
</body>
</html>
finally loader.js is as below
$(document).ready(function() {
$("#header").load("http://"+document.location.host+"/facturation/html/facturation-header");
$("#menu0").load("http://"+document.location.host+"/facturation/html/facturation-menu0");
$("#menu0-func0-panel").load("http://"+document.location.host+"/facturation/html/facturation-menu0-func0-panel", function() {
var option={
parent: "#stat-container",
type: "Pie",
labels: ['FACTURES EN ATTENTE', 'FACTURES EN RETARD (- DE 30 JOURS)', 'FACTURES EN RETARD (+ DE 30 JOURS)'],
data: [20, 15, 10],
colors: ["#0ae1ff", "#067180", "#dd4d40"],
canvasWidth: 250,
canvasHeight: 250,
legendType: "value",
legendPosition: "bottom",
legendUnit: "DZD",
overlay: false
};
chart(option);
});
$("#menu0-func1-panel").load("http://"+document.location.host+"/facturation/html/facturation-menu0-func1-panel");
$("#menu0-func2-panel").load("http://"+document.location.host+"/facturation/html/facturation-menu0-func2-panel");
$("#menu0-func3-panel").load("http://"+document.location.host+"/facturation/html/facturation-menu0-func3-panel");
});
to be honest, I don't have the slightest clue why I m getting this, nor an idea about what should I do or try.
NB: I m using zuul and eureka as mentioned, my service is named facturation that why I'm adding facturation after zuul address so he knows which service to contact
using this question I configured thymeleaf to get my pages from the classpath
Related
I am a student and I have to develop a rest app using Java Spring, and the app is an online marks register. I have a StudentController class where I implemented a method in Java to show all the subjects which a student has and the grades related to each subject. I have an array list of hash maps that link a subject with the grades related to it. My problem is that I have to display the results from the Hash Maps from inside the list in the Html and even though I tried some things from the internet, it does not work. Can you please help me? Thank you in advance.
Here is the Java method:
#RequestMapping(value = "student")
public ModelAndView showGrades()
{
ModelAndView modelAndView = new ModelAndView();
List<Subject> subjects = subjectRepo.findAll();
Student student = new Student();
Person person = session.getUser();
ArrayList<HashMap<Subject, ArrayList<Integer> >> grades = new ArrayList<HashMap<Subject, ArrayList<Integer> >>();
student.setName(person.getName());
student.setAccount(person.getAccount());
for(int i=0; i<subjects.size(); i++){
HashMap<Subject, ArrayList<Integer> > mappingGrades = new HashMap<Subject, ArrayList<Integer>>();
Random rand = new Random();
ArrayList<Integer> studentGrades = new ArrayList<Integer>();
studentGrades.add(rand.nextInt(10));
studentGrades.add(rand.nextInt(10));
studentGrades.add(rand.nextInt(10));
mappingGrades.put(subjects.get(i), studentGrades);
student.setGrades(mappingGrades);
grades.add(mappingGrades);
}
modelAndView.addObject("grades", grades);
return modelAndView;
}
And here is the HTML code including my try for printing:
<!DOCTYPE html>
<html>
<head>
<!-- Site made with Mobirise Website Builder v4.11.4, https://mobirise.com -->
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="generator" content="Mobirise v4.11.4, mobirise.com">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
<link rel="shortcut icon" href="assets/images/logo4.png" type="image/x-icon">
<meta name="description" content="">
<title>Student</title>
<link rel="stylesheet" href="assets/web/assets/mobirise-icons/mobirise-icons.css">
<link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="assets/bootstrap/css/bootstrap-grid.min.css">
<link rel="stylesheet" href="assets/bootstrap/css/bootstrap-reboot.min.css">
<link rel="stylesheet" href="assets/tether/tether.min.css">
<link rel="stylesheet" href="assets/dropdown/css/style.css">
<link rel="stylesheet" href="assets/theme/css/style.css">
<link rel="preload" as="style" href="assets/mobirise/css/mbr-additional.css">
<link rel="stylesheet" href="assets/mobirise/css/mbr-additional.css" type="text/css">
</head>
<body>
<section class="header1 cid-rLBDn2JTwv" id="header16-9">
<div class="container">
<div class="row justify-content-md-center">
<div class="col-md-10 align-center">
<h1 class="mbr-section-title mbr-bold pb-3 mbr-fonts-style display-1">
GRADES
</h1>
<p class="mbr-text pb-3 mbr-fonts-style display-5">
Subjects and related grades.
</p>
</div>
</div>
</div>
</section>
<section class="engine">bootstrap theme</section>
<section class="services5 cid-rLBDGcNu8T" id="services5-b">
<!---->
<!---->
<!--Overlay-->
<!--Container-->
<div class="container">
<div class="row">
<!--Titles-->
<div class="title pb-5 col-12">
</div>
<!--Card-1-->
<div class="card px-3 col-12">
<div class="card-wrapper media-container-row media-container-row">
<div class="card-box">
<div class="top-line pb-3">
<h4 class="card-title mbr-fonts-style display-5">
<table>
<tbody>
<form action="student" method="showGrades">
<div th:each="map : ${grades}">
<div th:each="mapEntry : ${map}">
<span th:text="${mapEntry.key}"></span> =
<span th:text="${mapEntry.value}"></span>
</div>
</div>
</form>
</tbody>
</table>
</h4>
<p class="mbr-text cost mbr-fonts-style m-0 display-5">
$400
</p>
</div>
<div class="bottom-line">
</div>
</div>
</div>
</div>
<!--Card-2-->
<!--Card-3-->
<!--Card-4-->
<!--Card-5-->
<!--Card-6-->
<!--Card-7-->
<!--Card-8-->
<!--Card-9-->
<!--Card-10-->
<!--Card-11-->
<!--Card-12-->
</div>
</div>
</section>
<script src="assets/web/assets/jquery/jquery.min.js"></script>
<script src="assets/popper/popper.min.js"></script>
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
<script src="assets/tether/tether.min.js"></script>
<script src="assets/smoothscroll/smooth-scroll.js"></script>
<script src="assets/dropdown/js/nav-dropdown.js"></script>
<script src="assets/dropdown/js/navbar-dropdown.js"></script>
<script src="assets/touchswipe/jquery.touch-swipe.min.js"></script>
<script src="assets/theme/js/script.js"></script>
</body>
</html>
In the code you supplied the value of mapEntry.key is a Subject object and the value of mapEntry.value is an ArrayList. You need to tell thymeleaf how to output those objects. If Subject has a proper toString method it will work as you expect but an ArrayList will not print properly. You need to use another nested each statement or you need to join it into a single string.
I want to fetch data from different servers according to client id.
PS: everything is running on https, stackoverflow does not allow me to put more then 2 links, thats why I removed https part.
Let say, My proxy controller server is running on - 192.168.2.0:8080
I have multiple servers, let say server A on 192.168.2.20:8080 and server B on 192.168.2.30:8080.
If, my user aaa is hitting on proxy controller it should get response from server A, if user bbb is hitting on proxy server it should get response from server B.
eg. 192.168.2.0:8080/api/aaa/ui/index.html should actually call 192.168.2.20:8080/ui/index.html and client should get response.
Same for bbb user, in that case response should come from 192.168.2.30:8080/ui/index.html.
This use case is working for static content, but not for dynamic contents. I am not able to get dynamic data from the server.
I guess internally my server is giving me
Code on my controller.
Controller
This handles the URL and invoke this function.
it will take a URL like, http://localhost:8080/userId/ui/index.html
and calls a server according to the userId, UserId can be aaa or bbb.
#RequestMapping(value = "/{userId}/**", method= RequestMethod.GET)
#ResponseBody
public String HTTPControllerEntry(#PathVariable("userId") String userId,HttpServletRequest request){
String urlEndSubstring = (String)request.getAttribute(
HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
int index = urlEndSubstring.indexOf('/',1 + urlEndSubstring.indexOf('/'));
urlEndSubstring = urlEndSubstring.substring(index+1);
String URL = userId+urlEndSubstring;
String response=httpRedirectionService.RedirectHttpUrl(userId, urlEndSubstring);
return response;
}
This function will get the prefix of the URL on the bases of userId and genrate the full URL with the specific ipaddress of the user.
#Override
public String RedirectHttpUrl(String userId, String urlEndSubstring) {
UserConnectionProperties ucP = new UserConnectionProperties();
String urlPrefix= ucP.readUserConnectionProperty(userId);
String URL = urlPrefix+urlEndSubstring;
return callURL(URL);
}
This function just get the http request and return it back to the controller. Controller will be returning back to the client.
private String callURL(String httpURL) {
System.out.println("Requeted URL: " + httpURL);
StringBuilder sb = new StringBuilder();
URLConnection urlConn = null;
InputStreamReader in = null;
try {
URL url = new URL(httpURL);
urlConn = url.openConnection();
if (urlConn != null)
urlConn.setReadTimeout(60 * 1000);
if (urlConn != null && urlConn.getInputStream() != null) {
in = new InputStreamReader(urlConn.getInputStream(),
Charset.defaultCharset());
BufferedReader bufferedReader = new BufferedReader(in);
if (bufferedReader != null) {
int cp;
while ((cp = bufferedReader.read()) != -1) {
sb.append((char) cp);
}
bufferedReader.close();
}
}
in.close();
} catch (Exception e) {
System.out.println(("Exception while calling URL:"+ httpURL +" "+e+"\n"));
}
return sb.toString();
}
This will give the ipaddress of the internal server acccording to the userId
public String readUserConnectionProperty(String key){
Properties prop = loadPropertyfile();
return prop.getProperty(key);
}
To load the property file.
private Properties loadPropertyfile(){
Properties props = new Properties();
InputStream is = null;
try {
File f = new File("userConnection.properties");
is = new FileInputStream(f);
}
catch (Exception e){
is = null;
}
try {
if ( is == null ) {
is = getClass().getClassLoader().getResourceAsStream("userConnection.properties");
}
if(is!=null){
props.load( is );
}
else {
throw new FileNotFoundException("property file userConnection not found in class path");
}
}
catch ( Exception e ) { }
return props;
}
userConnection.properties
aaa=192.168.2.120:8080/
bbb=192.168.2.130:8080/
ccc=192.168.2.140:8380/
My Html file which I got from get request on my server with aaa as a user.
<html lang="en" ng-app="UI">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>UI</title>
<link type="text/css" href="css/bootstrap.min.css" rel="stylesheet">
<link type="text/css" href="css/angular-material.min.css" rel="stylesheet">
<!-- custom css files -->
<link type="text/css" href="css/components.css" rel="stylesheet">
<link type="text/css" href="css/layout.css" rel="stylesheet">
<link type="text/css" href="css/views.css" rel="stylesheet">
<link type="text/css" href="css/theme.css" rel="stylesheet">
<!-- Icons/Fonts -->
<link type="text/css" href="fonts/md-icons/md-icons.css" rel="stylesheet" media="all">
<link type="text/css" href="css/roboto-fontface.css" rel="stylesheet" media="all">
<meta name="apple-mobile-web-app-capable" content="yes" />
</head>
<body ng-controller="BodyController">
<div id="authentication" data-access-token="{{ACCESS_TOKEN}}"></div>
<div ng-include="'partials/include.extension.html'"></div>
<nav class="menu slide-menu-left" ng-controller="NavController">
<div class="top clickable" ng-click="navigateToRoot()">
<img id="logo" alt="Logo" src="img/logo.png" />
<h1 class="title">App</h1>
</div>
<ul>
<li ng-class="{active: isActive('control'), hidden: isHidden('control')}">
<a href="#control">
<span class="icon md-icon-dashboard"></span> Control</a>
</li>
<li ng-class="{active: isActive('inbox')}">
<a href="#inbox" class="clickable">
<span class="icon md-icon-add-circle-outline"></span> Inbox
<span ng-show="getNumberOfNewDiscoveryResults() > 0" class="badge">{{getNumberOfNewDiscoveryResults()}}</span>
</a>
</li>
<li ng-class="{active: isActive('configuration'), hidden: isHidden('configuration')}">
<a ng-click="open('configuration')" class="clickable">
<span class="icon md-icon-settings"></span> Configuration</a>
<ul ng-show="isActive('configuration')">
<li ng-class="{active: isSubActive('bindings')}">Bindings</li>
<li ng-class="{active: isSubActive('services')}">Services</li>
<li ng-class="{active: isSubActive('groups'), hidden: isHidden('groups')}">Groups</li>
<li ng-class="{active: isSubActive('things')}">Things</li>
</ul>
</li>
<li ng-class="{active: isActive('extensions'), hidden: isHidden('extensions')}">
<a href="#extensions">
<span class="icon md-icon-extension"></span>
Extensions</a>
</li>
<li ng-class="{active: isActive('rules'), hidden: isHidden('rules')}">
<a href="#rules">
<span class="icon md-icon-movie-creation"></span>
Rules</a>
</li>
<li ng-class="{active: isActive('preferences'), hidden: isHidden('preferences')}">
<a href="#preferences">
<span class="icon md-icon-brightness-medium"></span>
Preferences</a>
</li>
</ul>
<div class="bottom">
<span>UI</span>
</div>
</nav>
<div id="wrapper">
<header>
≡
<div class="title">
<h1>
{{title}}
<span ng-repeat="subtitle in subtitles" class="subtitle">
<span class="chevron md-icon-chevron-right"></span> {{subtitle}}</span>
</h1>
</div>
</header>
<ng-view autoscroll="true"></ng-view>
<footer> </footer>
</div>
<!-- lib js files -->
<script src="js/angular.min.js"></script>
<script src="js/angular-bundle.min.js"></script>
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<!-- TODO: Create custom variant to save space -->
<script src="js/tinycolor.js"></script>
<script src="js/masonry.pkgd.min.js"></script>
<!-- TODO: Use angularized version? -->
<script src="js/sprintf.min.js"></script>
<!-- custom js files -->
<script src="js/app.js"></script>
<script src="js/constants.js"></script>
<script src="js/services.min.js"></script>
<script src="js/controllers.min.js"></script>
<script src="js/extensions.js"></script>
<script src="js/main.js"></script>
<script src="js/shared.properties.js"></script>
</body>
</html>
I'm using scribe to connect with QTIWorks
I found this question How to create a oAuth request using java?
I write this QTIWorks class
package testscribe;
import org.scribe.builder.api.DefaultApi10a;
import org.scribe.model.Token;
import org.scribe.model.Verb;
public class QTIWorks extends DefaultApi10a {
#Override
public Verb getRequestTokenVerb()
{
return Verb.GET;
}
#Override
public String getRequestTokenEndpoint() {
return "https://webapps.ph.ed.ac.uk/qtiworks-dev2/lti/domainlaunch";
}
#Override
public String getAccessTokenEndpoint() {
return "none";
}
/*#Override
public String getAuthorizationUrl(Token requestToken) {
return "none";*/
#Override
public String getAuthorizationUrl(Token token) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}
and this is Main class
package testscribe;
import org.scribe.builder.ServiceBuilder;
import org.scribe.model.OAuthRequest;
import org.scribe.model.Response;
import org.scribe.model.Token;
import org.scribe.model.Verb;
import org.scribe.oauth.OAuthService;
public class Main {
public static void main(String[] args){
OAuthService service = new ServiceBuilder().provider(QTIWorks.class).apiKey("gmail.com/zeina.helwani").apiSecret("v6wPuluQXPwX3vva71ZpR7i1fsbGPaT6")
.scope("API.Public").build();
Token requestToken = service.getRequestToken();
OAuthRequest request = new OAuthRequest(Verb.POST,"https://webapps.ph.ed.ac.uk/qtiworks-dev2/lti/domainlaunch");
service.signRequest(requestToken, request);
Response response = request.send();
System.out.println(response.getBody());
}
}
but it is give me this error
Exception in thread "main" org.scribe.exceptions.OAuthException: Response body is incorrect. Can't extract token and secret from this: '
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>QTIWorks - Method Not Allowed (HTTP Error 405)</title>
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Open+Sans:400,400italic,700,700italic|Ubuntu:500">
<link rel="stylesheet" href="/qtiworks-dev2/lib/960/reset.css">
<link rel="stylesheet" href="/qtiworks-dev2/lib/960/text.css">
<link rel="stylesheet" href="/qtiworks-dev2/lib/fluid960gs/grid.css">
<link rel="stylesheet" href="/qtiworks-dev2/includes/qtiworks.css?v=1.0-SNAPSHOT">
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.min.css">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>
<script src="/qtiworks-dev2/includes/qtiworks.js?v=1.0-SNAPSHOT"></script>
<!--[if lt IE 9]><script src="/qtiworks-dev2/lib/html5shiv.min.js"></script><![endif]-->
</head>
<body class="page">
<div class="container_12">
<header class="pageHeader">
<h1>QTIWorks</h1>
</header>
<h2>Method Not Allowed (HTTP Error 405)</h2>
<p>You used an HTTP method which is not allowed here.</p><h3>Further Details</h3>
<strong>Message:</strong> Request method 'GET' not supported<br>
<strong>Status Code:</strong> 405<br>
<strong>Request URI:</strong> /qtiworks-dev2/lti/domainlaunch<br>
<div class="clear"></div>
<footer>
<div class="logos">
<img src="/qtiworks-dev2/includes/images/jisc75.png" width="75" height="50" alt="JISC Logo" />
<img src="/qtiworks-dev2/includes/images/uoe.png" width="60" height="60" alt="University of Edinburgh Logo" />
</div>
<div class="copyright">
<p>
QTIWorks 1.0-SNAPSHOT ‒ Release notes
</p>
<p>
Copyright © Thu Apr 09 13:16:35 BST 2015
The School of Physics and Astronomy,
The University of Edinburgh.
</p>
<p>
Contact: David McKain
</p>
<p>
The University of Edinburgh is a charitable body, registered in Scotland,
with registration number SC005336.
</p>
</div>
</footer>
</div>
</body>
</html>
at org.scribe.extractors.TokenExtractorImpl.extract(TokenExtractorImpl.java:41)
at org.scribe.extractors.TokenExtractorImpl.extract(TokenExtractorImpl.java:27)
at org.scribe.oauth.OAuth10aServiceImpl.getRequestToken(OAuth10aServiceImpl.java:64)
at org.scribe.oauth.OAuth10aServiceImpl.getRequestToken(OAuth10aServiceImpl.java:40)
at org.scribe.oauth.OAuth10aServiceImpl.getRequestToken(OAuth10aServiceImpl.java:45)
at testscribe.Main.main(Main.java:24)
Java Result: 1
I think this url "https://webapps.ph.ed.ac.uk/qtiworks-dev2/lti/domainlaunch" is invalid, but I don't know what I should use.
I am adding a parameter in the url of the page of I was trying to go but in the generated url it is not being shown, why is that?
Here's my jsp.
<%# taglib prefix="s" uri="/struts-tags"%>
<%# taglib prefix="sj" uri="/struts-jquery-tags"%>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<sj:head ajaxhistory = "true" ajaxcache="true" />
<script>
</script>
</head>
<body>
<h5>Struts Jquery Ajax Integration</h5>
<div id="resultContent"></div>
<noscript>Please Turn On Javascript to make the full use of this site</noscript>
<h4>Choose A task</h4>
<ul>
<s:url value="views/ajaxvalidation.jsp" var="ajaxvalidation" >
<s:param name="menuId" value="1"/>
</s:url>
<li><sj:a targets="resultContent" href="%{ajaxvalidation}">Ajax Validation</sj:a></li>
</ul>
<div>
<h6>Play A Music while You Navigate</h6>
<audio src="x.mp3" controls>Your browser does not support the
audio element.
</audio>
</div>
</body>
</html>
The URL That is being shown is this
http://localhost:8090/HelloStruts2/#resultContent=_sj_action_anchor_860825673resultContent
Where is the menuId parameter that I have added in the url?
I do not know if this will make a difference but I am using this plugin for jquery.
struts2-jquery
Generated HTML
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script type="text/javascript" src="/HelloStruts2/struts/js/base/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="/HelloStruts2/struts/js/base/jquery.ui.core.min.js?s2j=3.5.0"></script>
<script type="text/javascript" src="/HelloStruts2/struts/js/plugins/jquery.subscribe.min.js"></script>
<script type="text/javascript" src="/HelloStruts2/struts/js/plugins/jquery.ba-bbq.min.js"></script>
<script type="text/javascript" src="/HelloStruts2/struts/js/struts2/jquery.struts2.min.js?s2j=3.5.0"></script>
<script type="text/javascript">
$(function() {
jQuery.struts2_jquery.version="3.5.0";
jQuery.scriptPath = "/HelloStruts2/struts/";
jQuery.struts2_jquery.ajaxhistory = true;
jQuery.ajaxSettings.traditional = true;
jQuery.ajaxSetup ({
cache: false
});
jQuery.struts2_jquery.require("js/struts2/jquery.ui.struts2.min.js");
jQuery(window).trigger('hashchange');
});
</script>
<link id="jquery_theme_link" rel="stylesheet" href="/HelloStruts2/struts/themes/smoothness/jquery-ui.css?s2j=3.5.0" type="text/css"/>
<script>
</script>
</head>
<body>
<h5>Struts Jquery Ajax Integration By Kyel</h5>
<div id="resultContent"></div>
<noscript>Please Turn On Javascript to make the full use of this site</noscript>
<h4>Choose A task</h4>
<ul>
<li><a id="anchor_2068827505" href="javascript:void(0)">Ajax Validation</a>
<script type='text/javascript'>
jQuery(document).ready(function () {
var options_anchor_2068827505 = {};
options_anchor_2068827505.jqueryaction = "anchor";
options_anchor_2068827505.id = "anchor_2068827505";
options_anchor_2068827505.targets = "resultContent";
options_anchor_2068827505.href = "views/ajaxvalidation.jsp";
options_anchor_2068827505.hrefparameter = "menuId=1";
jQuery.struts2_jquery.bind(jQuery('#anchor_2068827505'),options_anchor_2068827505);
});
</script></li>
<li><a id="anchor_1381525763" href="javascript:void(0)">Thank you JSP</a>
<script type='text/javascript'>
jQuery(document).ready(function () {
var options_anchor_1381525763 = {};
options_anchor_1381525763.jqueryaction = "anchor";
options_anchor_1381525763.id = "anchor_1381525763";
options_anchor_1381525763.targets = "resultContent";
options_anchor_1381525763.href = "views/thankyou.jsp";
options_anchor_1381525763.hrefparameter = "menuId=2";
jQuery.struts2_jquery.bind(jQuery('#anchor_1381525763'),options_anchor_1381525763);
});
</script></li>
</ul>
<div>
<h6>Play A Music while You Navigate</h6>
<audio src="x.mp3" controls>Your browser does not support the
audio element.
</audio>
</div>
</body>
Use action tag and use nested param tag see below code .
<s:url id="login" action="admin/showProfile" var="profileUrl">
<s:param name="user">Rais</s:param>
</s:url>
<a href='<s:property value="#profileUrl"/>'>
<s:property value="#profileUrl"/></a>
I'm using GWT 2.0, GWT-Ext 1.5 & Java 1.6 with Mozilla 3.6.x.
I'm trying to implement ThemeChanger module as per this link. But I'm not able to achieve it. Can anyone look at my code & tell me what am I missing or doing wrong?
Test.html
<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link type="text/css" rel="stylesheet" href="ThemeTest.css">
<link id="theme" rel="stylesheet" type="text/css" href="/public/resources/themes/green/css/xtheme-green.css"/>
<link id="theme" rel="stylesheet" type="text/css" href="/public/resources/themes/red/css/xtheme-red.css"/>
<link id="theme" rel="stylesheet" type="text/css" href="/public/resources/themes/gray/css/xtheme-gray.css"/>
<link id="theme" rel="stylesheet" type="text/css" href=""/>
<title>Web Application Project</title>
<script type="text/javascript" language="javascript" src="themetest/themetest.nocache.js"></script>
</head>
<body>
<iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe>
<noscript>
<div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif">
Your web browser must have JavaScript enabled
in order for this application to display correctly.
</div>
</noscript>
</body>
</html>
Test.gwt.xml
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='test'>
<inherits name='com.google.gwt.user.User'/>
<inherits name='com.gwtext.GwtExt' />
<inherits name='com.google.gwt.user.theme.standard.Standard'/>
<stylesheet src="resources/css/ext-all.css" />
<stylesheet src="resources/css/style.css" />
<script src="adapter/ext/ext-base.js" />
<script src="ext-all.js" />
<entry-point class='com.test.client.ThemeTest'/>
<source path='client'/>
<source path='shared'/>
</module>
EntryPointClass: ThemeTest.java
#Override
public void onModuleLoad() {
FormPanel formPanel = new FormPanel();
formPanel.setTitle("Form");
TextField nameField = new TextField("Name");
TextField descField = new TextField("Desc");
formPanel.add(nameField);
formPanel.add(descField);
formPanel.add(new ThemeChanger());
RootPanel.get().add(formPanel);
}
ThemeChanger.java
public class ThemeChanger extends ComboBox {
public ThemeChanger() {
final Store store = new SimpleStore(new String[]{"theme", "label"}, new Object[][]{
new Object[]{"/public/resources/themes/green/css/xtheme-green.css", "Green"},
new Object[]{"", "Aero Glass"},
new Object[]{"/public/resources/themes/red/css/xtheme-red.css", "Red"},
new Object[]{"/public/resources/themes/gray/css/xtheme-gray.css", "Gray"},
});
store.load();
setFieldLabel("Select Theme");
setEditable(false);
setStore(store);
setDisplayField("label");
setForceSelection(true);
setTriggerAction(ComboBox.ALL);
setValue("Gray");
setFieldLabel("Switch theme");
addListener(new ComboBoxListenerAdapter() {
public void onSelect(ComboBox comboBox, Record record, int index) {
try {
String theme = record.getAsString("theme");
CSS.swapStyleSheet("theme", theme);
} catch (Exception e) {
e.printStackTrace();
}
}
});
setWidth(100);
}
}
Check your locations of themes.
You can download gxt-2.2.1.zip.
Extract it on your computer. there will be a directory named resources containing themes
which you need to copy at your project location.
I have checked your code by palcing below example values
new Object[]{"/test/resources/themes/slate/css/xtheme-slate.css", "Slate"},
new Object[]{"/test/resources/themes/access/css/xtheme-access.css", "Access"},
In ThemeChanger classs with themes given in above .jar
It worked.