Wednesday, 15 July 2015

jsf - How to update value of EditableValueHolder in action listener? -


itemprop = "text">

I have this JSF (provided by Java EE7, Glassfish 4.1 + PrimFace 5.1) in which the database connection such as host name Information, port number, etc. Part of this form is also a URL field. I want this field to be editable, but I want to be able to set the value based on other fields.

To do this, I created a button with an action listener where I created the data and generated new URL value. Then I want to put the new value in the URL field and want to use that value instead of the data posted. To achieve the ingredient I have tried and to set the present value.

XHTML:

  and lieutenant  

; P: Input Text id = "url" size = "50" value = "# {database.url}" /> & Lt; P: Command button icon = "ui-icon-arrowrefresh-1-w" instant = "true" action-id = "# {database.createConnectionURL ('Naming Container')}" & gt; & Lt; P: Ajax update = "url" /> & Lt; / P: CommandButton & gt;

Bean (experiment):

  UIcomputer urlComponent = Faces.getViewRoot (). FindComponent (Naming Container + "URL"); If (Editable Validator of the URL Component Presentation) {EditableValueHolder editValHolder = (EditableValueHolder) urlComponent; EditValHolder.setSubmittedValue (urlValue); } Faces.getContext (). RenderResponse ();    

instant = "true" is left with a JSF 1.x, when it was not possible to set only on a special input and / or buttons, it was more often than that instead it was misused to process only for a specific set and / or button. You can not use it better when JSF2Ajax comes in your hands

With JSF2 Ajax you can only use execute = "..." Or process only a specific set of input / button for the execution of the primary formus process = "..." .

  & lt; P: inputText id = "url" size = "50" value = "# {database.url}" /> & Lt; P: Command button icon = "ui-icon-arrowrefresh-1-w" process = "@ this" verb = "# {database.createConnectionURL ('naming container')}" update = "url" />  

Then you can simply update the model value.

  Create Public Zero CONNECTIONURL (String Naming Container) {// ... url = urlValue; }  

Note that I have & lt; P: ajax update & gt; in & lt; P: commandButton & gt; went back. Maybe you could & lt; H: commandButton & gt; were mixing with.


unrelated , in solid problems, dealing with components with OmniFaces Use the utility class better.


No comments:

Post a Comment