私はvaadin 7についてあまりよく知らないので、これを理解できません。私はGoogleを使用しようとしたが、有用な結果は得られなかった。vaadin 7 URLパラメータ
私の質問はとても簡単です。 UIクラスでリクエストURLパラメータを取得するにはどうすればよいですか?
私のURLは、パラメータがあります。host/myvaadinapp/?code=erefdvdfgftf...
urlパラメータは、(OAuthの)にログインしたユーザの後にFacebookのから来ていると私は私のコードでは、コードのURLパラメータの値を処理する必要があります。
私はこれらを実行しようとしました:
@PreserveOnRefresh
public class AdminUi extends UI
{
@Override
protected void init(VaadinRequest request)
{
...
System.out.println(request.getPathInfo());
System.out.println(request.getRemoteHost());
System.out.println(request.getParameterMap().size());
System.out.println(request.getAttribute("code"));
System.out.println(request.getParameter("code"));
...
}
}
結果: request.getAttribute( "コード"):ヌル request.getParameter( "コード"):ヌル
私はgetParameterMap(ことに気づきました)には "v-loc"パラメータがあります。私はそれを使用する場合でも、変数、私は、この変数からURLパラメータを取得するためにいくつかのコードを記述する必要があります。
V-LOC:host/myvaadinapp/?code=erefdvdfgftf...
テーマ:-600 V-dston: V-rtzoトナカイ偽 を...
私はそれがあまりにも良い解決策ではないと思います。
vaadinで元のURLパラメータを取得するにはどうすればよいですか?
ありがとうございます。
私のコメントは以下のとおりです。
私はrequest.getParameter( "コード")を使用しようとしたが、それは働いていませんでした。何故かはわからない。
私の元のURLをしたhost/demoVaadinApp/?name=zzz
私はこのコードを使用:
public class Xxxx extends UI
{
/**
* Main UI
*/
@Override
protected void init(VaadinRequest request)
{
String name = request.getParameter("name");
if (name == null)
{
name = "Unknown";
}
setContent(new Label("Hello " + name));
}
}
私は埋め込みUIモードで自分のvaadinアプリケーションを起動します。私のweb.xmlファイルの
内容:
<!-- ******************************************************************* -->
<!-- context parameters -->
<!-- ******************************************************************* -->
<context-param>
<description>Vaadin production mode</description>
<param-name>productionMode</param-name>
<param-value>false</param-value>
</context-param>
<!-- ******************************************************************* -->
<!-- servlet definition -->
<!-- ******************************************************************* -->
<!-- +++++ Vaadin servlet +++++++++++++++++++++++++++++++++++++++++++++ -->
<servlet>
<servlet-name>VaadinServlet</servlet-name>
<servlet-class>com.vaadin.server.VaadinServlet</servlet-class>
<init-param>
<description>Vaadin UI class</description>
<param-name>UI</param-name>
<param-value>com.coupoholics.ui.admin.AdminUi</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>VaadinServlet</servlet-name>
<url-pattern>/VAADIN/*</url-pattern>
</servlet-mapping>
<!-- ******************************************************************* -->
<!-- welcome file list definition -->
<!-- ******************************************************************* -->
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
のindex.html:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<script type="text/javascript" src="./VAADIN/vaadinBootstrap.js"></script>
<iframe tabindex="-1" id="__gwt_historyFrame" style="position: absolute; width: 0; height: 0; border: 0; overflow: hidden" src="javascript:false"></iframe>
<div id="content-body">
<!-- Optional placeholder for the loading indicator -->
<div class=" v-app-loading"></div>
<!-- Alternative fallback text -->
<noscript>You have to enable javascript in your browser to use this application.</noscript>
</div>
<!-- Initializing the UI -->
<script type="text/javascript">
//<![CDATA[
if (!window.vaadin)
alert("Failed to load the bootstrap JavaScript:" + "VAADIN/vaadinBootstrap.js");
/* The UI Configuration */
vaadin.initApplication("content-body", {
"browserDetailsUrl": "VAADIN",
"serviceUrl": "VAADIN",
"widgetset": "com.vaadin.DefaultWidgetSet",
"theme": "reindeer",
"versionInfo": {"vaadinVersion": "7.0.5"},
"vaadinDir": "VAADIN/",
"heartbeatInterval": 300,
"debug": true,
"standalone": false,
"authErrMsg": {
"message": "Take note of any unsaved data, "+
"and <u>click here<\/u> to continue.",
"caption": "Authentication problem"
},
"comErrMsg": {
"message": "Take note of any unsaved data, "+
"and <u>click here<\/u> to continue.",
"caption": "Communication problem"
},
"sessExpMsg": {
"message": "Take note of any unsaved data, "+
"and <u>click here<\/u> to continue.",
"caption": "Session Expired"
}
});//]]>
</script>
</body>
私の結果は次のとおりです。 こんにちは不明。
埋め込みUIモードを使用しないと、すべてがうまくいきます。
問題はどこですか?
溶液(レイフÅstrandをありがとうございました):
するvar urlParts = window.location.href.splitを( "?");
var queryString =(urlParts.length == 1)? "": "?" + urlParts [1];
queryString =(urlParts.length == 0)? "":queryString.split( "#")[0];
と
"browserDetailsUrl": "VAADIN" +のqueryString、
完全なソースコード:
<!-- Initializing the UI -->
<script type="text/javascript">
var urlParts = window.location.href.split("?");
var queryString = (urlParts.length == 1) ? "" : "?" + urlParts[1];
queryString = (urlParts.length == 0) ? "" : queryString.split("#")[0];
//<![CDATA[
if (!window.vaadin)
alert("Failed to load the bootstrap JavaScript:" + "VAADIN/vaadinBootstrap.js");
/* The UI Configuration */
vaadin.initApplication("content-body", {
"browserDetailsUrl": "VAADIN" + queryString,
"serviceUrl": "VAADIN",
...
あなたの答えをありがとう! 私はそれを解決し、上記の私の解決策を共有しました。 – zappee