我使用 seam 框架,我想在我的项目中集成tokeninput 自动完成插件。
我成功地进行了集成并将数据保存在数据库中,但问题是当我在验证时提交表单时,数据丢失了h:inputtext
,在编辑输入文本时也是空的。
<ui:define name="head">
<head>
<script type="text/javascript" src="js/jquery/jquery.tokeninput.js"></script>
<link rel="stylesheet" type="text/css" href="js/jquery/token-input.css" media="screen"/>
<link rel="stylesheet" type="text/css" href="js/jquery/token-input-mac.css" media="screen"/>
<link rel="stylesheet" type="text/css" href="js/jquery/token-input-facebook.css" media="screen"/>
<script>
$(document).ready(function() {
$("div.permiss input").tokenInput("http://shell.loopj.com/tokeninput/tvshows.php", {
theme: "facebook",
});
});
</script>
</head>
</ui:define>
<ui:define name="body">
<body>
<h:form id="permission" styleClass="edit">
<rich:panel>
<f:facet name="header">#{permissionHome.managed ? 'Edit' : 'Add'} Permission</f:facet>
<s:decorate id="nomPermissionField" template="layout/edit.xhtml">
<ui:define name="label">Nom permission</ui:define>
<div class="permiss">
<h:inputText id="nomPermission" required="true" value="#{permissionHome.instance.nom}"/>
</div>
</s:decorate>
<s:decorate id="targetPermissionField" template="layout/edit.xhtml">
<ui:define name="label">Target permission</ui:define>
<div class="voici1" >
<h:inputText id="targetPermission" cols="80" rows="10" required="true" value="#{permissionHome.instance.target}"/>
</div>
</s:decorate>
<s:decorate id="DiscriminatorPermissionField" template="layout/edit.xhtml">
<ui:define name="label">Discriminator permission</ui:define>
<h:selectOneMenu id="selectdisc" value="#{permissionHome.instance.discriminator}" required="true">
<f:selectItem id="si0" itemLabel=" " itemValue=" "/>
<f:selectItem id="si1" itemLabel="role" itemValue="role"/>
<f:selectItem id="si2" itemLabel="user" itemValue="user" />
</h:selectOneMenu>
</s:decorate>
<div style="clear:both">
<span class="required">*</span>
required fields
</div>
</rich:panel>
<div class="actionButtons">
<h:commandButton id="save" value="Savee" action="#{permissionHome.persist}"
oncomplete="javascript:window.parent.location.reload(true);"
disabled="#{!permissionHome.wired}"
rendered="#{!permissionHome.managed}"/>
<h:commandButton id="update" value="Save" action="#{permissionHome.update}" rendered="#{permissionHome.managed}"/>
<h:commandButton id="delete" value="Delete" action="#{permissionHome.remove}" immediate="true" rendered="#{permissionHome.managed}"/>
<s:button id="cancelEdit" value="Cancel" propagation="end" view="/Permission.xhtml" rendered="#{permissionHome.managed}"/>
<s:button id="cancelAdd" value="Cancel" propagation="end" view="/#{empty permissionFrom ? 'PermissionList' : permissionFrom}.xhtml" rendered="#{!permissionHome.managed}"/>
</div>
</h:form>
</body>
</ui:define>