I need to determine the form field id from the action handler. The field is part of the included facelets component, so the shape will change.
included.xhtml
<ui:component> <h:inputText id="contained_field"/> <h:commandButton actionListener="#{backingBean.update}" value="Submit"/> </ui:component>
example_containing.xhtml
<h:form id="containing_form"> <ui:include src="/included.xhtml"/> </h:form>
How to determine the form identifier in a method updateat runtime? Or better yet, the ID of the input field directly.
update
Bind the button to your bean support, then use getParent () until you find the closest form.
jsight. ( JSF , ), . h: form , , Form: containsfield. : JSF, , , (parentNamingContainerId:) * componentId
Since the update method is of type actionListener, you can access your user interface component as follows
public void update(javax.faces.event.ActionEvent ac) { javax.faces.component.UIComponent myCommand = ac.getComponent( ); String id = myCommand.getId(); // get the id of the firing component ..... your code ......... }
Source: https://habr.com/ru/post/1697409/More articles:Has anyone used Boo and can you comment on your experience? - .netjava sound without hardware device - javaz-index cannot overcome iframe value - cssInvalid group name: group names must begin with a word character - c #how to determine if a record in each source represents the same person - algorithmVisual Studio Window Manager - .netFixed TD height property in HTML - htmlПроблема производительности IIS, пытающаяся реализовать XMPP-подобный протокол - performancePerformance Reports - performanceМожет ли TDD работать в среде архитектора/исполнителя? - tddAll Articles