jsf 2 - jsf 2.x use a similar <c:set> behavior inside a <h:datatable> -
i trying jsf 2.x <h:datatable> , need <c:set> behavior inside it. here code,
<h:column id="passcol"> <f:facet id="passfct" name="header">password</f:facet> <h:inputtext value="#{tech.password}" rendered="#{(tech.id).trim() == (technicianbean.technicianid).trim()}"/> <h:outputtext value="#{tech.password}" rendered="#{(tech.id).trim() != (technicianbean.technicianid).trim()}"/> </h:column> what pretending should follows,
<h:column id="passcol"> <f:facet id="passfct" name="header">password</f:facet> <c:set property="inputfield" target="#{mybean}" value="#{tech.password}" /> <h:inputtext value="#{mybean.inputfield}" rendered="#{(tech.id).trim() == (technicianbean.technicianid).trim()}"/> <h:outputtext value="#{tech.password}" rendered="#{(tech.id).trim() != (technicianbean.technicianid).trim()}"/> </h:column> being tech var setting in datatable. way can catch tech.password input field let me work (e.g.: update).
how can achieve behavior?
thanks.
jsf has reference of collection of elements it's iterating over. having case:
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"> <h:head /> <h:body> <h:form> <h:datatable value="#{bean.itemslist}" var="item"> <h:column> <h:inputtext value="#{item.value}" /> </h:column> </h:datatable> <h:commandbutton action="#{bean.update}" value="submit" /> </h:form> </h:body> even #{item.value} not directly referencing managed bean, input component, jsf knows write value. if use managed bean you'll notice when clicking 'submit' list of values table referencing being updated. indeed, code print out updated values of list when click button.
@managedbean @viewscoped public class bean { public class item { private string value; public item(string val) { value = val; } public string getvalue() { return value; } public void setvalue(string value) { this.value = value; } @override public string tostring() { return "item [value=" + value + "]"; } } private list<item> itemslist = arrays.aslist(new item("value1"), new item( "value2")); public list<item> getitemslist() { return itemslist; } public void update() { system.out.println(itemslist); } }
Comments
Post a Comment