1
doen't工作我試圖隱藏和使用JQuery展示我的文字區JSF。但它不起作用。條件很好,但功能不起作用。 有什麼問題?我並不是最新的JS,但我開始探索JSF,並在這裏以非常奇怪的方式使用JS。 在這裏你可以在下面看到我的代碼。 感謝名單顯示和隱藏功能在JSF
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:b="http://bootsfaces.net/ui"
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
<h:head>
<title>Add new field</title>
</h:head>
<h:body>
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js">
</script>
<h:form>
<b:commandButton look="link" action="response?faces-redirect=true"
value="Response" />
<b:commandButton look="link" action="fields?faces-redirect=true"
value="Fields" />
</h:form>
<h:form style="margin: 0 auto">
<h3>Adding Form Components</h3>
<h:panelGrid columns="1">
<h:outputLabel id="label" for="label">Label:</h:outputLabel>
<div>
<b:inputText binding="#{infoManageBean.labelInput}"
placeholder="Name, Country, etc." required="true" id="labelText"
value="#{infoManageBean.field.label}">
</b:inputText>
<p:message for="labelText" />
<h:outputText value="#{addFieldValidationBean.label}" />
<br /> <br />
</div>
<h:outputLabel for="type">Type:</h:outputLabel>
<b:selectOneMenu onchange="handleChange(this.value)" required="true"
value="#{infoManageBean.field.type}">
<f:selectItems value="#{fieldManageBean.getFieldTypes()}"
var="value" itemLabel="#{value}" itemValue="#{value}" />
</b:selectOneMenu>
<br />
<br />
<h:inputTextarea id="itemArea" cols="30" rows="10" />
<h:outputLabel for="color">Required:</h:outputLabel>
<b:selectBooleanCheckbox value="#{infoManageBean.field.required}">
</b:selectBooleanCheckbox>
<h:outputLabel for="color">Is active:</h:outputLabel>
<b:selectBooleanCheckbox value="#{infoManageBean.field.isActive}" />
<input type="hidden" name="method" value=" ADD " />
<b:commandButton look="primary" binding="#{infoManageBean.button}"
id="addFieldBtn" validateClient="true"
action="#{infoManageBean.insertOrUpdateField()}"></b:commandButton>
</h:panelGrid>
</h:form>
<script type="text/javascript">
function handleChange(selection) {
var COMBO_BOX = 'COMBO_BOX';
if (selection == COMBO_BOX) {
console.log('visible');
$('#itemArea').show();
} else {
console.log('hidden');
$('#itemArea').hide();
}
}
</script>
</h:body>
</html>
感謝名單。有用。瘋狂的JSF。討厭它 –
太棒了。該ID前綴聽起來很瘋狂,但你會發現它是有用的,當你重複使用的組件和片斷,因爲它有助於避免IDS崩潰 –