Populating textbox in jsf on clicking submit button

I am having inputText box, dropdownlist , outputText box and a submit button in my jsp page.
I am pre populating the dropdown list from my managed bean. Also setting the values using setter methods that is input in inputText box and dropdownlist using managed bean.
On clicking the submit button and based on selected item from the drop down list, I need to perform populating outputText box with return string from getter method from bean.
But I am not sure how to handle this. Please find few lines of code below...
<h:inputText id= "mnNum" value="#{UserBean.mnNum}" size="18" maxlength="17" styleClass="TxtSz12 LH18" tabindex="1" title="Man Number"/>
<h:selectOneMenu id="lstService" value="#{UserBean.serviceType}" tabindex="3">
   <f:selectItems value="#{UserBean.getServiceItems}"/>
</h:selectOneMenu>
<h:commandButton  action="#{UserBean.submit}" id="submitButton" value="Generate"/>
<h:outputText value="#{UserBean.getRequest}" />
public class UserBean extends FacesBean {
public String submit() {...}
public void setServiceType(String serviceType) {...}
public String getRequest() {
if(serviceType.toString()=="SearchService")
return "abc";
else if (serviceType.toString()=="basicService")
return "xyz";
else
return null;
}Please assist how to do it when submit button is clicked. I can redirect to different jsp file on click of the submit button. But I dont want to do that and I need to populate the output textbox in the same page !
If anything is not clear please let me know. Thanks in advance.
Edited by: 901007 on Jan 13, 2012 4:11 AM
Edited by: 901007 on Jan 13, 2012 4:13 AM

Page is coming up but lstService dropdown box is not displayed at all. But mnNum inputText and submitButton is showing properly.
Also after pressing submit button, "abc" text must be displayed in outputText box. But its also not displayed. Instead, the below error is shown,
Error opening /portlets/tools/webservicehelper/webservicehelper.faces.
The source of this error is:
java.util.MissingResourceException: Can't find bundle for base name resources.bundles.ValidationMessages, locale en at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1521) at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1260) at java.util.ResourceBundle.getBundle(ResourceBundle.java:962) at javax.faces.component.MessageFactory.getMessage(MessageFactory.java:102) at javax.faces.component.MessageFactory.getMessage(MessageFactory.java:175) at javax.faces.component.UIInput.validateValue(UIInput.java:1001) at javax.faces.component.UISelectOne.validateValue(UISelectOne.java:130) at javax.faces.component.UIInput.validate(UIInput.java:868) at
Any problems in below code?
My entire code below for UserBean.java and webservicehelper.jsp.
package net.verizon.portlet.bean;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.component.UIInput;
import javax.faces.context.FacesContext;
import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.Map;
import javax.faces.*;
import javax.faces.model.*;
import java.util.*;
public class UserBean extends FacesBean {
     private static final long serialVersionUID = 1L;
     private String mnNum;
     private String serviceType;
     private String txtVal;
     public String getmnNum() {
          return mnNum;
     public void setmnNum(String mnNum) {
          this.mnNum = mnNum.toUpperCase();
     public String getServiceType() {
          return serviceType;
     public void setServiceType(String serviceType) {
          this.serviceType = serviceType;
     private ArrayList<SelectItem> serviceItems = null;
     public ArrayList<SelectItem> getServiceItems() {
          serviceItems = new ArrayList<SelectItem>();
          serviceItems.add(new SelectItem(null,"select one..."));
          serviceItems.add(new SelectItem("SearchService","SearchService"));
          serviceItems.add(new SelectItem("basicService","basicService"));
          return serviceItems;
     public String submit() {
          try {                    
                     txtVal = "abc";
          catch(Exception e) {
                        logger.error("error in submit method" + e);
          return null;
     public String getRequesttxt() {
               return txtVal;
--webservicehelper.jsp
<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://bea.com/faces/adapter/tags-naming" prefix="netuix" %>
<%@ taglib uri="http://www.bea.com/servers/portal/tags/netuix/render" prefix="render" %>
<f:view>
     <h:form id="wnInputForm" onsubmit="return validateLoginForm();">
         <h:messages layout="table" globalOnly="true" style="color: red"/>
         <h:panelGrid columns = "2" width="100%">
              <h:panelGroup>
                   <h:panelGrid columns="1" cellpadding="6" width="400">
                   <h:panelGroup style="white-space: nowrap;">
                        <h:outputLabel value="Man Number" for="mnNum" escape="false"/>
                   </h:panelGroup>
              <h:panelGroup>
                   <h:inputText id= "mnNum" value="#{UserBean.mnNum}" size="18" maxlength="17" tabindex="1" title="Man Number"/>
              </h:panelGroup>
                   </h:panelGrid>
              </h:panelGroup>
              <h:panelGroup>
                   <h:panelGrid width="700">
                   <h:panelGroup>
                                  <h:outputText value="#{UserBean.requesttxt}" />
                        </h:panelGroup>
                   </h:panelGrid>
              </h:panelGroup>     
              <h:panelGroup>
                   <h:selectOneMenu id="lstService" value="#{UserBean.serviceType}" tabindex="3">
                        <f:selectItems value="#{UserBean.serviceItems}"/>
                   </h:selectOneMenu> <br>
                            <h:commandButton action="#{UserBean.submit}" id="submitButton" value="Generate"/>
              </h:panelGroup>
         </h:panelGrid>
           </h:form>
</f:view>Edited by: 901007 on Jan 16, 2012 8:07 AM

Similar Messages

  • Left Nav lost after clicking submit button in iView

    Hi Community,
    I created an APC called CreateOrder which implements AbstractPortalComponent. This component acts as controller. In doContent() method, It checks if the create order submit button is clicked or not, if no, it  returns createOrder.jsp page, if yes, it returns createOrderResult.jsp page. Everything works fine except left navigation disapear after I click submit button createOrder.jsp and createOrderResult.jsp shows up. 
    by the way I can create a createOrderIview using the APC component, able to see createOrder.jsp page and have result page shows up.
    Anyone know what problem here? any help/sugguestion are very appriciated.

    Make sure your iView isolation mode is set to URL...
    Cheers

  • How to set focus on MessageTextInput after clicking submit button

    Hi All,
    I have submit button and MessageTextInput, by clicking submit button i have to focus on MessageTextInput control.
    can any one tell me how to do this?
    Thanks
    Laukik Pachanekar

    Hi,
    As the submit button is clicked redirect the page to itself using
    pageContext.forwardimmediatelytocurrentpage(null,false,null);
    Now in process request use:
    import oracle.apps.fnd.framework.webui.beans.OABodyBean;
    OABodyBean oabean = (OABodyBean)pageContext.getRootWebBean();
    oabean.setInitialFocusId("<id of messsage text input>");
    Thanks,
    Gaurav

  • Can we remain in the same state even after clicking submit button?

    Hello All,
    Can we remain in the same stage even after clicking submit button? Also it should remain in the same stage only when certain conditions are met. For eg:
    Condition : In Stage1, CustomFieldA default value is 'No'. To pass from Stage1 to Stage2 the CustomFieldA value should be made to yes.
    Scenario 1 : CustomFieldA value is 'No', and I click on Submit .
    Expected Result : should remain in the same stage
    Is above result achievable in PS 2013? I am creating workflow in Visual Studio 2012, so can I handle this in the workflow?
    Please help.

    The above answer was proved wrong, so please follow this link to get the answer.
    http://social.msdn.microsoft.com/Forums/en-US/8c75d74d-1ea6-4273-96cd-e70f5a5688fc/how-to-remain-in-the-same-stage-even-after-clicking-submit-button?forum=project2010custprog

  • How to open a new OAF page in new window while clicking submit button

    Dear All
    I am facing one problem.I have to pass some parameter in new page only after validation.I can't do validation in processRequest bacause I perform validation after clicking the submit button.
    So I have to write redirect code in processForm Request. I can not use simple "Button" bean since I have to set destination uri which could be set only in processRequest.But I can not pass parameter with it in process request.
    Thats why I have decided to use submit button but there is not target frame option in property inspector,So I am not able to open it in new window.
    Kindly give me some suggestion .
    Thanks in Advance

    hi,
    u can use submit button. U need to handle submit button press in processFormRequest method.
    if(pageContext.getParameter("Submit"!=null))
    // validate your parameter
    if parameter u capturing are valid then...
    pageContext.setForwardURL(func, params ...............) // check devguide for details
    if u want to access these parameter in second page . you can write this logic to processRequest of target page.
    U can refer toolbox tutorial drilldown and createpage examples for implementation details.
    Regards,
    Ram

  • Error while clicking submit button?

    Hi All,
    I am trying to implement selectOneListbox component. This displays all the data which I required. I am also able to retrieve indiviual data. I checked this using alert in java script.
    The problem which I am facing is that I have a command button on the page. Once I click the submit button. I am getting an error.
    org.apache.jasper.JasperException: javax.servlet.jsp.JspException: Duplicate component ID 'form1:_id0' found in view.
    I am unable to proceed. Please let me know any solution for the problem.
    Regards
    Rishab

    HI All,
    I have fixed this issue. This was problem with RSA. The id was not getting generated. So explicitly I added the id and it worked.

  • Safari needs to click submit button twice when file uploading

    Hi all,
    I'm using Safari 4.0.5 and developing the html (no AJAX, but plain PHP posting) form with the file uploading on my local environment. I tested it fast and thick several times, then suddenly Safari stopped to upload the jpeg file, indicating loading animation on the address bar. So I tried to click the submit button once again, I succeed in sending two posts including one jpeg image.
    There's no problem with other browsers like Firefox and Chrome. Additionally, I tried to reinstalled Safari, rebooted Snow Leopard and checked file's permissions by Disk Utility app, but no dice.
    Any suggestions would be greatly appreciated.
    Thanks,

    I am having the exact same problem except that I'm in Safari 5.0. Did you ever come to any resolution on the problem?
    I am having trouble uploading certain jpegs (can't find a common thread between the images that won't work though they tend to be larger than 100k and larger than 800px wide). When I have the problem the progress bar just hangs at about 10%. The page never times out. Never throws any kind of error. I confirmed that the file is never making it to the application layer. Such a weird and intermittent problem. All other browsers are fine. Just Safari is a problem. Even with these images that are giving me a problem, sometimes they work - especially after restarting the browser.
    Any help or insight from anyone would be greatly appreciated.
    Message was edited by: Neal Ferrazzani

  • Skillbuilder Modal popup turns black when click submit button

    Hi,
    Ive used the great skill-builder's plug-in to display my page 2 popup modally from page1 by clicking a button and it works as expected. However i realized when i click the Submit button on the popup page it turns black(pls get me right here its the background of the popup page-page2 not the first page-page1 i am talking about) while refreshing.
    apex 4.1.0/Oracle 11g Ent,
    any help please...regards.

    Skillbuilder Modal uses software named "Colorbox" for its modal presentation. The first problem that you had probably occured because you had not yet selected a theme. The position of the close button varies depending on the theme that you select. You selected theme 1, therefore the close button is in the lower right hand corner. Some of the other themes may better suit your taste. There are 5 to choose from. BTW, these themes cannot be easily changed so you pretty much have to decide on 1 of the 5. I think Dan is working on some more options with future releases of SB Modal.

  • Save pdf file to folder on click submit button

    Hi,
    Does anyone knows how to save a currently open pdf file to a specific directory folder when the submit button is clicked? Is it possible to be done using javascript or formcalc?
    Thanks,
    Cindy

    Hi Cindy,
    You can check out the following threads.
    Re: How to save PDF forms using javascript events
    Re: How to SAVE pdf doc in hard disk programatically
    Re: Offline Interactive Form Using Download - how to store a file on the WAS?
    Hope this helps.

  • Data inserting two times in a table  when i click submit button

    Hi Experts,
    I had a problem, when i am inserting data in a table from a form at the first time when i click button it adds two times, afterwards it is adding one time only, the form and table are from same value node (table is collection cardinality : 1..n and selection cardinality is 0..n) i don't understand why it  is happening here?
    Regards,
    Pradeep Kumar

    Hi Pradeep,
    Please check the method for inserting data in a table. May be method is called two times.
    Post your code here to look into it.
    Best Regards,
    Arun Jaiswal

  • When we click Submit button in CSC, I want to redirect to differrent panel

    Hi All
    There is one panel for member search in CSC. from some other form I want to redirect to this 'member search' panel. what should be done?
    Thanks & Best regards,
    Pratik

    you can do this by incorporating the memberserach panel and the panel stack details in the atgSubmitAction, which can be triggered by any onClick event. For example if you have a button, onclicking the button if you want to submit and redirect tot he membersearch panel you can have somethng similar to below one
    <dspel:input type="button" value="submitForm" name="submitButton" bean="TestFormHandler.submitForm" onclick="submitForm();"/>
    and the javascript function for the submit action is something like below, replace the memberSearchPanelName and the memberSearchPanelStackName with corresponding panel and panel stack names for the member search form u have
    <script type="text/javascript">
    submitButton=function(){
    var submitForm=dojo.byId("submitPanelForm"); //get the form to be submitted
    atgSubmitAction({
    form: submitForm,
    panels: ["memberSearchPanelName"],
    panelStack: ["memberSearchPanelStackName"]
    </script>
    HTH
    Thanks,
    Rajesh Akavaram

  • Is it possible write code inside pdf form when click submit button in pdf form

    can write code to pdf form
    for eg:
    we have to write code in Excel sheet using Macro features Like that any possible to write code in pdf form
    when i downloaded pdf form from site then filled up the details then click the save button the pdf form will send to the corresponding server then stored in DB
    pls reply me soon

    You have posted in a completely wrong forum. This one is exclusively for participants testing features of the site.
    You may want to try reposting in the appropriate Acrobat forum, which you can find here:
    http://forums.adobe.com/community/acrobat?view=overview

  • To click submit button when I press Enter

    I want to activate my SUBMIT link(not button) when I press the "ENTER" button in my Key board. I am using Struts.
    Message was edited by:
    ashish.0532
    Message was edited by:
    ashish.0532

    You have to use javascript to do this. Most browsers only support default buttons, not links.

  • SUBMIT button works only when clicked twice... Online interactive form

    Hi,
    I have created a interactive form with SubmitToSAP button. In this I will enter a contract number and will click SUBMIT button.
    For the first time it is fetching the contract details properly.
    In the same form, i am changing  the previously entered value with another contract number and clicking SUBMIT.
    Now the details for the previously entered contract number is only displayed. Again if i try for the same value ( which i used for the second time )  and press submit, it is workin correctly.
    So, the problem is, except for the very first time SUBMIT button action, the button works fine only when clicked twice..
    please help me in solving this issue..
    Regards,
    Surya.

    Hi,
        In addition to my previous post, I am also using RESET FORM button from Library.
    First I am entering the contract number (say 400000000) in the form and clicking submit button. The contract details are fetched and displayed in the form.
    Now i am Resetting the form using Reset Button, and giving new contract number (say 400000020).  When  I pressed Submit button , the details of the first entered contract number (400000000)  is coming.
    Then again I am giving 400000020 or any other number, it is fetching the details correctly for that number...
    Can anyone help me in this issue..
    Thanks,
    Surya.

  • Double Click handling with Submit Button

    Does a submitButton on the page automatically handle / block the user's double click action?
    I have an application where a submit button causes processing & commits to occur.
    I want to make sure that when the user "double-click" the button, it doesn't cause problems.
    Thanks

    Hi
    Does a submitButton on the page automatically handle / block the user's double click action?No it doesnot handles so..
    You can write the below code in processRequest method of your controller to disable the button till the moment processing is going on,After processing completes you can again click submit button.
    OAWebBean body = pageContext.getRootWebBean();
    if(body instanceof OABodyBean)
    ((OABodyBean)body).setBlockOnEverySubmit(true);
    }Please refer to this article for more details
    http://mukx.blogspot.com/2009/12/blocking-user-on-submit-action-in-oaf.html
    Moreover,if you want to disable the button after first click then on click of get an event redirect it to same page and make it disabled or use Partial page rendering for this.
    Thanks
    AJ

Maybe you are looking for