<t:if test="needsSetName">
<label for="userfunction">${message:setname}</label>
<t:textfield
t:mixins="zoneUpdater"
tabindex="-1"
autofocus="false"
ZoneUpdater.clientEvent="keyup"
ZoneUpdater.event="valueChangedSetName"
ZoneUpdater.zone="transferZone"
ZoneUpdater.timeout="3000"
t:id="setName"
value="setName"/>
</t:if>
@OnEvent(value = "valueChangedSetName")
protected void onValueChangedSetName(@RequestParameter(value = "param", allowBlank = true) String setName)
{
TransferOrder to = baskets.getTransferOrder();
this.setName = setName;
to.setComment("Rename from " + this.setName + " to " + setName);
nextSetName = setName;
zoneHubService.updatePendingTransfer();
zoneHubService.addCallback(new JavaScriptCallback()
{
@Override
public void run(JavaScriptSupport javascriptSupport)
{
javascriptSupport.addScript(
String.format("var thing=jQuery('#%s'); thing.focus();thing[0].setSelectionRange(10000, 10000);",
setNameField.getClientId()));
}
});
}
所以我的问题是,当我在文本字段中键入一些文本时,它会删除#,&amp;,...之类的符号以及这些符号之后的所有其他内容
当我使用+时,它会变成空间
我在我的方法中从服务器获得的字符串已经被编辑了#34;。
我是挂毯和ajax的新手,我不知道如何解决这个问题。
我该怎么办,以便在没有服务器删除这些符号的情况下从服务器返回字符串?
答案 0 :(得分:0)
我解决了我的问题
在我的zone-updater.js中,我不得不在我的字符串上使用encodeURIComponent
对于任何遇到相同问题的人来说,这是指向zoneUpdater.js代码的链接
http://tinybits.blogspot.com/2010/03/new-and-better-zoneupdater.html
我发现解决这个错误的链接I已经关闭了。
define([“jquery”,“t5 / core / zone”],function($,zoneManager){
return function(elementId, clientEvent, listenerURI, zoneElementId, timeout) {
var $element = $("#" + elementId);
var mytimeout;
if (clientEvent) {
$element.on(clientEvent, updateZone);
}
function updateZone() {
jQuery($element).removeClass('saved');
if (mytimeout != null) {
clearTimeout(mytimeout);
}
mytimeout = setTimeout(function() {
var listenerURIWithValue = listenerURI;
if ($element.val()) {
listenerURIWithValue = appendQueryStringParameter(
listenerURIWithValue, 'param', $element.val());
listenerURIWithValue = appendQueryStringParameter(
listenerURIWithValue, 'element', elementId);
}
zoneManager.deferredZoneUpdate(zoneElementId,
listenerURIWithValue);
}, timeout);
}
}
function appendQueryStringParameter(url, name, value) {
if (url.indexOf('?') < 0) {
url += '?'
} else {
url += '&';
}
value = encodeURIComponent(value);
url += name + '=' + value;
return url;
}
});