InputText and selectOneMenu

I have one inputText and one selectOneMenu and I want if the user chooses any one of the combobox, the value will add in the text field. I tried it on JavaScript, and it's quite easy. But now I have to implement by using JSF.
My code is below:
aa.jsp
<h:inputText id="abc" value="#{rHandler.abc}" size="10" required="true" />
<h:selectOneMenu id="def" value="#{rtHandler.def}" immediate="true" onchange="this.form.submit();" valueChangeListener="#{rHandler.changeList}">
<f:selectItems value="#{rHandler.defChoices}" />
</h:selectOneMenu>
rHandler.java
private String abc = null;
private int def;
private boolean judge;
public void changeList(ValueChangeEvent event){
judge = !judge;
abc = "hello";
FacesContext.getCurrentInstance().renderResponse();
I changed the string value in the function changeList. But the value in the jsp file didn't change. What's going on?

When you set the property in the bean, you set it in the "model". However, the page in rendered based on the data from the component tree, but from the "model" in your case.
You have to create a component binding for text field and change the value using it.
Sergey : http://jsfTutorials.net

Similar Messages

  • How do I put an af:InputText and af:CommandButton on the same line?

    How do I put an af:InputText and af:CommandButton horizontally level with each other in my JSPX page?
    atm they sit on top of each other which is no good. Must I contain each item inside a form or something??

    Hi, you can do it this way:
            <af:panelGroupLayout layout="horizontal">
              <af:inputText label="Label 1"/>
              <af:commandButton text="commandButton 1" id="button1"/>
            </af:panelGroupLayout>Regards,
    Branislav

  • H:inputText and immediate="true" not updating cached backing bean value

    Hi,
    I am having a problem with h:inputText and immediate="true" when
    returning back to the same page.I looked through the forums but the
    only solution to remove the page from the session works only if I
    don't have to change any button label names in the page I am going back
    to.Unfortunately, I have to change a button name when I go back to the
    same page.The button name change works if i don't remove the page from
    session but then h:inputtext has stale values in it from the backing
    bean.I also need to avoid validation as it is a huge form.
    I have tried looking through the JSF forums but they didn't have any
    answers for a very similar question.
    I am not sure how exactly to use component binding for the input text and update the model values using an actionListener.I have tried puting a binding on an input text field and then used an actionListener instead of immediate="true' in the h:commandLink.But, putting context.renderResponse() in the actionListener method results in the model values not getting updated.
    I have also tried using component.processUpdates(facesContext) as in the UpdateModelValuePhase class -that too doesn't work.
    Thanks for any help,
    Vijay
    Details:
    The <h:inputText ..> does not populate the values back from a backing
    bean when immediate="true" is used when an action is called.
    <h:commandLink id="selectPrincipalId"
    action="#{application.selectPrincipal}" immediate="true">
    Only <h:inputText has the cached values from the first entry.
    <h:inputText id="principalLastName1Id"
    value="#{application.currentPrincipal.lastName}" size="10"/><== this
    has the cached value from the backing bean application.
    <h:outputText gets the new values from the backing bean when the same
    page is reentered.
    <h:outputText value="#{application.currentPrincipal.lastName}"></h:outputText><==
    this refreshes with the new value from the backing bean application.
    Here is the solution to rectify the problem:
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ExternalContext externalContext = facesContext.getExternalContext();
    Map sessionMap = externalContext.getSessionMap();
    sessionMap.remove("/jsp/befg/tc/apply/enterCreditApplication.jsp");
    <== this is the name of the jsf page as defined in the
    faces-config.xml.

    Hi,I have encountered the same problem as you,and I find a solution myself,which is shown as follows,but I don't know if these is any hidden trouble in the code.
    <h:form>
    <h:commandLink action="#{app.action}" immediate="true" actionListener="#{app.update}">xxxx</h:commandLink>
    <h:inputText id="_id" value="#{app.val}" immediate="true"/> //must set immediate="true" else the model will be not updated
    <h:message for="_id"/>
    </h:form>
    public class App{
    public void update(ActionEvent event){
         FacesContext c = FacesContext.getCurrentInstance();
         UIViewRoot root =c.getViewRoot();
         root.processUpdates(c);//to update model and short-circuit the validators
    in such circumstance,the UIViewRoot's processUpdates method will be called in the actionlistener,and the back bean who titled to immediate(true)'s inputText will be updated, but the one who titled to immdiate(false)'s inputText will not be updated,Why?
    Can anyone tell me way?and how to solve?
    Thanks a lot!

  • How can I control the width of an inputText and commandButton components

    I need to set the width for both &lt;af:inputText/&gt; and &lt;af: CommandButton/&gt; , but I couldn&rsquo;t find the width property in the &ldquo;Property inspector&rdquo; for them, Is there a way to do it ? Thanks.

    Msrping,
    Always mention the Version of Jdeveloper which you are using.
    If you are using Jdeveloper 11.1.1.0.1 than try this:
    <af:inputText/> :: Goto Property Inspector > Appearance > Column(Set the value for this property. ex, 10)
    <af: CommandButton/> :: Goto Property Inspector > style > Box tab > width(Set the value for this property, ex, 50)
    ---Neelmani Jaiswal

  • InputText and secret="true": do not display stars

    Hi,
    I use ADF ea15.
    I have two af:inputText. One is secret, the other not.
    I use component binding for both (CoreInputText objects) because I need to disable these fields on some conditions.
    When I select an entry in a SelectOneListbox on the same page (with immediate="true" and autoSubmit="true"), the value change listener that is called sets the value of both input text (values are not empty) using coreInputText.setSubmittedValue().
    The value for the non secret field is updated in the page but the value of the secret input is BLANK. I would have thought that there would have been stars like ******** in the secret input. Is it a normal behaviour or did I make something wrong ? Note that the only difference between both fields is the secret="true".
    Thanks for your response.
    Patrick

    In Firefox 3.6 the Java plugin is treated just like all other plugins and no longer has a enable check box in Tools > Options > Content.
    You can enable or disable all plugins including [[Java]] via Tools > Add-ons > Plugins
    See also http://kb.mozillazine.org/Java

  • Problem with a datatable and selectOneMenu

    Hello
    I'm pretty new at java, so this might be an easy problem to solve, but I've been stuck in this for a couple of days now, so any help will be appreciated.
    I have a selectOneMenu item that when it's changed this value loads the info for a datatable below it, this works fine.... but I need that when for example, the select one menu has the value "1", the data tabla loads the activities for the option "1", inside the datatable there is a checkbox for a column, now, in this scenario, when I check 3 options in the datatable, I need to change the value in the selectOneMenu and put, for example the value "2", when this happens now I have to reload the datatable with the values corresponding to the activities for the option "2".
    The problem is when I change the value of the selectOneMenu on the backingBean, because this selectOneMenu has implemented the onchange event, but this is only activated if the the value is changed in the UI, not in the code as I need to do it.
    This are the lilbs that I'm using:
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
    <%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    This is the fragment of code of the selectOneMenu:
    <h:selectOneMenu id="ddlTipoVisita" value="#{VisitaDomiciliarBean.idTipoVisita}" disabled="#{VisitaDomiciliarBean.modoEdicion == false}"
    rendered="#{VisitaDomiciliarBean.mostrarSegunOpcionMenu}">
    <f:selectItems value="#{VisitaDomiciliarBean.selectItemsTipoVisita}" />
    <a4j:support status="statustablaSubtipoVisita" event="onchange" action="#{VisitaDomiciliarBean.cargarTablaSubtipoVisita}" reRender="tablaSubtipoVisita">
    </a4j:support>
    </h:selectOneMenu>
    This is the datatable section:
    <t:dataTable id="tablaSubtipoVisita" styleClass="scrollerTable2" headerClass="standardTable_Header"
    footerClass="standardTable_Header" rowClasses="standardTable_Row1,standardTable_Row2"
    columnClasses="columna_centrada" value="#{VisitaDomiciliarBean.subtiposVisita}" var="subtipo"
    preserveDataModel="false" rows="10" >
    <%--columna de seleccion multiple--%>
    <t:column rendered="#{VisitaDomiciliarBean.seleccionMultiple == true}">
    <f:facet name="header">
    <h:outputText value="#{recursos['actividades.seleccionar']}" />
    </f:facet>
    <a4j:region>
    <h:selectBooleanCheckbox
    value="#{subtipo.seleccionado}" disabled="#{VisitaDomiciliarBean.modoEdicion == false}">
    <a4j:support event="onchange" status="statustablaSubtipoVisita"
    actionListener="#{VisitaDomiciliarBean.seleccionar}" reRender="ddlTipoVisita" >
    </a4j:support>
    </h:selectBooleanCheckbox>
    </a4j:region>
    </t:column>
    <t:column>
    <f:facet name="header">
    <h:outputText value="#{recursos['actividades.descripcion']}"/>
    </f:facet>
    <h:outputText value="#{subtipo.descripcion}"></h:outputText>
    </t:column>
    </t:dataTable>
    Is there any way to do this using the rendered option of the components? Or does anybody has another idea or recomendation?
    I tried to solve it using two data tables, one for the option "2" and another for all the rest of the options, I tried to hide or show the one I need acoording to the data inside the array that has the info for the datatables, but this failed, because when I change the value for the selectOneMenu from the bean, both datatables are shown and not only the one that I need.
    I would really appreciate any help with this!
    Greetings,

    Well turns out I had a some bad code in the back end that was resetting the model to the 'initial' value. I didn't require the FacesContext.getCurrentInstance().renderResponse(); after all.
    But I still find it disturbing the model generator code being called twice.
    If anyone has any suggestions on how to prevent this I'm all ears.

  • h:inputText and UIInput

    Hi all,
    I know I can create a Textbox with <h:inputText>.
    Can I do the same without writing <h:inputText> tag in JSP (i.e. by using UIInput in my Bean)?
    If so, how?
    If I get this, can I expect the same logic for remaining components also?

    Hi,I have encountered the same problem as you,and I find a solution myself,which is shown as follows,but I don't know if these is any hidden trouble in the code.
    <h:form>
    <h:commandLink action="#{app.action}" immediate="true" actionListener="#{app.update}">xxxx</h:commandLink>
    <h:inputText id="_id" value="#{app.val}" immediate="true"/> //must set immediate="true" else the model will be not updated
    <h:message for="_id"/>
    </h:form>
    public class App{
    public void update(ActionEvent event){
         FacesContext c = FacesContext.getCurrentInstance();
         UIViewRoot root =c.getViewRoot();
         root.processUpdates(c);//to update model and short-circuit the validators
    in such circumstance,the UIViewRoot's processUpdates method will be called in the actionlistener,and the back bean who titled to immediate(true)'s inputText will be updated, but the one who titled to immdiate(false)'s inputText will not be updated,Why?
    Can anyone tell me way?and how to solve?
    Thanks a lot!

  • Jsf inputtext and a4j

    Hi all!
    I have a problem with the jsf inputtexts used with the ajax call made by a4j library.
    In a jsf page I've a list of item in a table.
    For each item in the table there are a button 'details' (a4j:commandButton).
    On click on this button appears another part of page (editpanel) in which I put all the info of the item.
    In the 'edit panel' I can edit some fields and then update them clicking on the button 'save'.
    If I click on the details button of another item the editpanel should change showing the details of new item clicked.
    It's all ok I in the editpanel I put the outputText element. But I need to put in the edit panel also inputText element, but the inputElement remain frozen on the first time content and the outputText change.
    Shortly...my question is...how can I update a inputText in a "area" updated after an ajaxCall?
    I'm sorry for my ugly english...:(
    Thanks all....

    When you set the property in the bean, you set it in the "model". However, the page in rendered based on the data from the component tree, but from the "model" in your case.
    You have to create a component binding for text field and change the value using it.
    Sergey : http://jsfTutorials.net

  • Converter and SelectOneMenu problem

    <h:selectOneMenu id="id_noofbeds" value="#{internals.numberofbeds}" converter="javax.faces.Integer">
    <f:selectItem itemValue="0" itemLabel="Studio" />
    <f:selectItem itemValue="1" itemLabel="1" />
    <f:selectItem itemValue="2" itemLabel="2" />
    <f:selectItem itemValue="3" itemLabel="3" />
    <f:selectItem itemValue="4" itemLabel="4" />
    <f:selectItem itemValue="5" itemLabel="5" />
    <f:selectItem itemValue="6" itemLabel="6" />
    <f:selectItem itemValue="7" itemLabel="7" />
    <f:selectItem itemValue="8" itemLabel="8+" />
    </h:selectOneMenu>
    I tried to run this code on my JSP page and have this in my backing bean:
    public Integer getNumberofbeds() {
    return numberofbeds;
    public void setNumberofbeds(Integer numberofbeds) {
    this.numberofbeds = numberofbeds;
    But when I run this code it always comes back with a validation error. I think it's because SelectOneMenu sends things back as a tuple, but not exactly sure how to handle it. Any help would be appreciated!!
    Tom

    See the javadoc of UISelectOne.validateValue(). It says:
    In addition to the standard validation behavior inherited from UIInput,
    ensure that any specified value is equal to one of the available options.
    If it is not, enqueue an error message and set the valid property to false.
    You specify the options as String literals using f:selectItem.
    So, the converted value which is type Integer is never equal to any of them.
    You can't use literal value of f:selectItem. Instead you may code as<f:selectItem itemValue="#{bean.option1}" itemLabel="1"/>Using f:selectItems may be better:<f:selectItems value="#{bean.options}"/>

  • Validate Multiple Inputtext and launch validation from backing bean

    Hi to all
    How can i validate multiple inputtext in a form?
    And how can i launch a validation from backin bean?
    Thanks

    Thank you very much, that is what i was looking for.
    I have one more problem:
    if i make this, it's showing me an error, i can't do it
    FacesContext context= FacesContext.getCurrentInstance();
    FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, null, "Value entered is invalid");
    msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, null, "component level message - Value entered is invalid");
    context.addMessage(FacesContext.getCurrentInstance().getViewRoot().findComponent("<id_of_the_inputtext_component"), msg);
    context.addMessage takes only two strings as arguments
    Edited by: 838674 on 23-mar-2011 4.56

  • Problem with inputText and autoTab="true"

    Hi to everyone
    I've a strange problem with the property autotab.
    if i have this situation:
    <af:inputText id="it1" columns="2" autoTab="true"
    maximumLength="2" autoSubmit="true">
    </af:inputText>
    <af:inputText id="it2" columns="1" maximumLength="1">
    </af:inputText>
    when the cursor pass from the first inputText to the second, the last character of the first inputText is cancelled. Anyone has the same problem? How can i solve it?
    Thanks in advance to everyone.

    use like this:
    <af:inputText id="it1" columns="1" autoTab="true"
    maximumLength="3" autoSubmit="true" partialTriggers="it2">
    </af:inputText>
    <af:inputText id="it2" columns="1" maximumLength="1" autoSubmit="true" autoTab="true" partialTriggers="it1 it3">
    </af:inputText>
    <af:inputText id="it3" columns="1" maximumLength="1" partialTriggers="it2">
    </af:inputText>

  • Required InputText and SelectOne

    Hi, would to ask if it's possible to fire the "required" validation once the user clicked on a button?
    Currently, if we set the required attribute to true of an inputText or selectOne, it will immediately
    activate or call the required validation.
    Thanks.

    hi sameera, I can't set autoSubmit = false because I need to render a different input text.
    Thanks for the reply, but I think we already found the solution to handle conditional rendering of input text with required validation by using switcher.

  • How can I validate a DataTable with inputText and other JSF components?

    I have a DataTable with various input components. I need to be able to validate what the user has entered on all the rows of the DataTable. Does anyone have any examples they can point me to, experiences with this, or knowledge on how to do this?
    Thank you so much.

    Do you have to use backing beans instead of managed beans to validate components inside a DataTable?

  • Strange effects in using f:convertNumber and h:inputText

    Hi everybody,
    I'm having really strange results with the following <h:inputText> and <f:convertNumber> tags in one JSF page:
    <h:inputText id="total" value="#{myBean.total}" required="true" size="10" ><f:convertNumber minFractionDigits="2" maxFractionDigits="2"/></h:inputText>
    When I enter the value 1585,9 for example, it is converted to 1 585,90 when I click on some link on the same page. And this is OK, since I'm using French locale. But when I click on the same link or something else, the value is changed to 1,00 !!! The other strange thing is that if I show the same value in a <h:outputText> tag, the value is always OK, that is I always have 1 585,90.
    Does anyone has any idea, and tell me how to solve this weird problem?
    Thanks
    Billy

    I found out after playing for a good time with different tests. The problem is that JSF uses NumberFormat to parse input string, and characters following an invalid character( space in my case ) are ignored! That's why I got just 1,00.
    So,the solution is to write a converter to handle this as follows:
    1. In method getAsString(): format the string according to the locale selected.
    2. In getAsObject(): remove any space in the input parameter, and return the appropriate value.

  • RadioButton and InputText

    Hey Guys!
    I was wondering...does anybody know
    how to set a radioButton to a list of input Texts in a nice way?
    I'll try to explian better,i need it for setting four answers to a question.
    The Admin user will enter his four answers in four InputTexts
    and will press the radioButton to determine which one is correct.
    Thanks!

    how to set a radioButton to a list of input Texts in a nice way?In a nice way? Can you please clarify the problem? What are you occurring and what do you want to approach?

Maybe you are looking for

  • The fixes dont work, can anybody help????

    I would be really grateful for someone's help. I have a Sony Vaio Media Center PC (XL301) and it came installed with Vista as the operating system. I am unable to play anything from sites that require the most up todate flash player; i.e. bbc iplayer

  • Ipod mini appears as "New Volume" in itunes

    After using my new ipod mini in itunes successfully, the ipod suddenly stopped appearing as "Mary's ipod" but instead is now "New Volume" and is not recognizing any songs on the mini. I can seemingly load music into the "New Volume" but this is not c

  • Issues syncing iPhone 5 and iPad mini with outlook calendars

    I am having issues syncing my iPhone 5 and iPad mini with Outlook calendar.  This is a new problem since I upgraded to IOS 7.  I am now using ios 7.0.2.  I have removed air sync for calendars and that has not resolved the issue.  Nothing new on my ca

  • T2000 Network Installation pause

    I'm seeing very strange behavior out of my two T2000 servers when I do a network installation. In short, it pauses for a very long time during the boot cycle. There is a pause for at least 45 minutes, sometimes even longer than that. Any help would b

  • Custom metadata properties give no results after upgrade from 2010

    Hi, Although I see my custom managed properties in my Search Schema in Central Admin, I am unable to find results using them e.g. 'VendorName:Marcel'. I have tried changing the column value in a document and performed a full crawl, but still no resul