मैं वैडिन 7 से बहुत परिचित नहीं हूं और मैं इसे समझ नहीं सकता। मैंने Google का उपयोग करने की कोशिश की लेकिन कोई उपयोगी परिणाम नहीं।vadin 7 यूआरएल पैरामीटर
मेरा प्रश्न बहुत आसान है। मैं अपने यूआई कक्षा में यूआरएल पैरामीटर का अनुरोध कैसे प्राप्त कर सकता हूं?
मेरे यूआरएल एक पैरामीटर है: host/myvaadinapp/?code=erefdvdfgftf...
url पैरामीटर उपयोगकर्ता में (OAuth) लॉग इन के बाद फेसबुक से आता है और मैं अपने कोड में कोड 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...
विषय: हिरन v-rtzo: -600 v-dston: झूठी ...
मुझे लगता है, यह बहुत अच्छा समाधान नहीं है।
क्या आप मेरी मदद कर सकते हैं मैं वैडिन में मूल यूआरएल पैरामीटर कैसे प्राप्त कर सकता हूं?
धन्यवाद।
मेरे टिप्पणी कर रहे हैं:
मैं request.getParameter ("कोड") का उपयोग करने की कोशिश की लेकिन यह काम नहीं किया गया था। मुझे नहीं पता क्यों।
मेरी मूल यूआरएल था: 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));
}
}
मैं एम्बेडिंग यूआई मोड में मेरी 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>
मेरे परिणाम है: हैलो अज्ञात।
यदि मैं सबकुछ ठीक से काम कर रहा हूं, तो मैं एम्बेडिंग यूआई मोड का उपयोग नहीं करता हूं।
समस्या कहां है?
समाधान (लीफ Åstrand के लिए धन्यवाद):
वर urlParts = window.location.href.split ("?");
var queryString = (urlParts.length == 1)? "": "?" + urlParts [1];
queryString = (urlParts.length == 0)? "": queryString.split ("#") [0];
और
"browserDetailsUrl": "VAADIN" + क्वेरी स्ट्रिंग,
पूर्ण स्रोत कोड:
<!-- 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