Passing radio button values to the backing bean

Hi all,
I need help with passing group of radio button values to a backing bean. I have page which has a dataTable to display a list of alerts. For each alert there are two radio buttons (YES & No) to indicate whether the email option for each alert is set or not. Now when i change the radio buttons and click on a submit button i should be able to pass these radio button values into action method in which i need to update the alerts. This is my code
<h:form>
<t:dataTable id="sub"
                   var = "alert"
                   value =#{subscriberBean.alertsList}">
<t:column>
<h:outputText value="#{alert.name}" />
</t:column>
<t:column>
<h:selectOneRadio id="subscriptions" value="#{alert.sendEmail}">
  <f:selectItem id="item1" itemLabel="Yes" itemValue="0" />
  <f:selectItem id="item2" itemLabel="No" itemValue="1" />
</h:selectOneRadio>
</t:column>
<t:dataTable>
<h:commandButton id="button1" value="Save changes" actionListener="#{subscriberBean.updateAlert}" />
</h:form>
{code}
I tried to to do something like below and get the updated list in the action event in the backing bean but it didn't work.
{code}
<h:commandButton id="button1" value="Save changes" actionListener="#{subscriberBean.updateAlert}" >
<f:attribute name="alerts" value="#{subscriberBean.alertsList}"/>
</h:commandButton>
// Backing Bean
public void updateAlert(ActionEvent e){
List<Alert updateList = (List<Alert>)event.getComponent().
                getAttributes().get("alerts");
{code}
Can someone advise how to get these update radio button values in my actionListener method.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

The value the user selected will be written to the sendEmail property of the managed bean named alert. We know this because you set the value attribute to #{alert.sendEmail}. So simply access the managed bean in your action method.

Similar Messages

  • UI Component (h:selectOneMenu) showing old value not matching backing bean

    Mojarra 2.1.7-jbossorg-1
    I'm out of my wits trying to figure out what is going on here.
    I have broken down the problem that I am seeing to something smaller test case that is easily reproducable.
    Two <h:selectOneRadio> ( Approved and Notified )
    One <h:selectOneMenu> wrapped in a <h:panelGroup>
    One <h:commandButton>
    The list of contents of the <h:selectOneMenu> is dependent on the value of the "Approved" <h:selectOneRadio>, and the list is obtained from the viewBean.
    Apart from the "required" attribute, the only other validation is a validator method in the bean that:
    If "Approved" radio button is Yes, and "Notified" radio button is No, then a ValidatorException is thrown and is shown on the <h:messages>
    Now the issue:
    1) Select Approved "Yes"
    2) Select Notified "No"
    3) Select dropdown to PEND
    4) Select Submit button
    5) <h:messages> show "Notified must be true when action is PEND". All good.
    6) Change Approved to "No" ... Note that there is a listener on change of Approved ... and the listener will always set the value of the dropdown to null.
    Because I changed the value of the Approved radio button, the dropdown selection is then changed to the "- Select- " item, which is what I am expecting as that is what the listener method does ... and the dropdown is re-rendered.
    7) Change Approved back to "Yes" ... dropdown changes back to PEND ... This is what I do not understand.
    Why was it being changed back to PEND when:
    A) The listener on the Approved radio button always sets the value of the dropdown to null in the backend.. and
    B) The Approved render attribute always re-render the dropdown
    <!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:h="http://java.sun.com/jsf/html"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:ui="http://java.sun.com/jsf/facelets">
    <h:head></h:head>
    <body>
    <h:form>
           <h:outputLabel value="Approved:"/>
           <h:selectOneRadio id="approved" value="#{viewBean.approved}"
                required="true"
                requiredMessage="Approved is required.">
                <f:selectItem itemValue="true" itemLabel="Yes"/>
                <f:selectItem itemValue="false" itemLabel="No"/>
                <f:ajax
                    event="valueChange"
                    execute="@this"
                    render="nextActionPanel"
                    listener="#{viewBean.triggerApprovedChange()}"/>
           </h:selectOneRadio>
           <h:outputLabel value="Notified:"/>
           <h:selectOneRadio id="notified" value="#{viewBean.notified}"
                required="true"
                requiredMessage="Notified is required."
                   validator="#{viewBean.validateNotified}">
                <f:selectItem itemValue="true" itemLabel="Yes"/>
                <f:selectItem itemValue="false" itemLabel="No"/>
                <f:ajax
                    event="valueChange"
                    execute="@this"
                    render="@none"/>
           </h:selectOneRadio>
            <h:panelGroup id="nextActionPanel">
           <h:selectOneMenu id="nextAction"
                 required="true"
                 requiredMessage="Next Action is required."
                 value="#{viewBean.nextAction}">
                 <f:selectItem itemValue="" itemLabel="- Select -" />
                 <f:selectItems
                     value="#{viewBean.availableNextActions}" var="target"
                     itemValue="#{target.value}"
                     itemLabel="#{target.label}"/>
                   <f:ajax
                    event="valueChange"
                    execute="@this"
                    render="@none"/>
           </h:selectOneMenu>
            </h:panelGroup>
           <h:commandButton id="submit" value="Submit"/><br/>
           <h:messages/>
    </h:form>
    </body>
    </html>
    package test;
    import java.io.Serializable;
    import java.util.ArrayList;
    import java.util.List;
    import javax.annotation.PostConstruct;
    import javax.faces.application.FacesMessage;
    import javax.faces.bean.ManagedBean;
    import javax.faces.bean.ViewScoped;
    import javax.faces.component.UIComponent;
    import javax.faces.context.FacesContext;
    import javax.faces.validator.ValidatorException;
    @ManagedBean
    @ViewScoped
    public class ViewBean implements Serializable {
         private static final long serialVersionUID = 1L;
         private Boolean approved;
         private Boolean notified;
         private String nextAction;
         private List<NextAction> availableNextActions;
         public Boolean getApproved() {
              return approved;
         public void setApproved(Boolean selection) {
              this.approved = selection;
         public Boolean getNotified() {
              return notified;
         public void setNotified(Boolean selection2) {
              this.notified = selection2;
         public String getNextAction() {
              return nextAction;
         public void setNextAction(String nextAction) {
              this.nextAction = nextAction;
         public void triggerApprovedChange() {
              changeAvailableNextActions();
              setNextAction(null);
         public List<NextAction> getAvailableNextActions() {
              return availableNextActions;
         private void setAvailableNextActions(List<NextAction> availableNextActions) {
              this.availableNextActions = availableNextActions;
         public void changeAvailableNextActions() {
              List<NextAction> nextActions = new ArrayList<NextAction>();
              if( Boolean.TRUE.equals( getApproved() )) {
                   nextActions.add( new NextAction("PEND", "Pend"));
              nextActions.add( new NextAction("REQADVICE", "Request Advice"));
              nextActions.add( new NextAction("FIN", "Finish"));
              setAvailableNextActions(nextActions);
         @PostConstruct
         public void init() {
              changeAvailableNextActions();
         public void validateNotified(
              FacesContext context,
            UIComponent toValidate,
            Object value)
              throws Exception
              List<FacesMessage> messages = new ArrayList<FacesMessage>();
              Boolean isNotified = (Boolean) value;
              if( Boolean.FALSE.equals( isNotified ) && "PEND".equals( nextAction )) {
                   FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR,
                        "Notified must be true when action is PEND", null);
                   messages.add( message );
              if( messages.size() > 0 ) {
                   throw new ValidatorException(messages);
         public class NextAction implements Serializable {
              private static final long serialVersionUID = 1L;
              private String label;
              private String value;
              public NextAction(String aValue, String aLabel) {
                   value = aValue;
                   label = aLabel;
              public String getLabel() {
                   return label;
              public String getValue() {
                   return value;
    }

    gimbal2 wrote:
    jmsjr wrote:
    Ok .. I am confused by what you just said .. as I did say that the same problem STILL exists in Mojarra 2.1.22.
    ergo .. It is not an issue with the usage of JSF but appears to be a bug in the implementation.I meant a bug in the old version that JBoss ships with. But I also mean in general; as you can see JSF 2.x is already on release 22 - the chance of you finding such an easy to trigger bug has become relatively slim. So no, I must assume it is actually a problem with not understanding how JSF ticks properly. Which is understandable since after using it for 5 years it still surprises me occasionally.
    The bug you link to is about values staying the same, not reverting back to a previous state.OK .. Maybe this will be more convincing (?). I change the xhtml so that it also displays ( via h:outputText ) .. the value of the backing bean that is the same value used for the h:selectOneMenu.
    <!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:h="http://java.sun.com/jsf/html"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:ui="http://java.sun.com/jsf/facelets">
    <h:head></h:head>
    <h:body>
    <h:form>
           <h:outputLabel value="Approved:"/>
           <h:selectOneRadio id="approved" value="#{viewBean.approved}"
                required="true"
                requiredMessage="Approved is required.">
                <f:selectItem itemValue="true" itemLabel="Yes"/>
                <f:selectItem itemValue="false" itemLabel="No"/>
                <f:ajax
                    event="valueChange"
                    execute="@this"
                    render="nextActionPanel"
                    listener="#{viewBean.triggerApprovedChange()}"/>
           </h:selectOneRadio>
           <h:outputLabel value="Notified:"/>
           <h:selectOneRadio id="notified" value="#{viewBean.notified}"
                required="true"
                requiredMessage="Notified is required."
                   validator="#{viewBean.validateNotified}">
                <f:selectItem itemValue="true" itemLabel="Yes"/>
                <f:selectItem itemValue="false" itemLabel="No"/>
                <f:ajax
                    event="valueChange"
                    execute="@this"
                    render="@none"/>
           </h:selectOneRadio>
            <h:panelGroup id="nextActionPanel">
            Backing Bean value for nextAction is '<h:outputText value="#{viewBean.nextAction}"/>'<br/>
           <h:selectOneMenu id="nextAction"
                 required="true"
                 requiredMessage="Next Action is required."
                 value="#{viewBean.nextAction}">
                 <f:selectItem itemValue="" itemLabel="- Select -" />
                 <f:selectItems
                     value="#{viewBean.availableNextActions}" var="target"
                     itemValue="#{target.value}"
                     itemLabel="#{target.label}"/>
                   <f:ajax
                    event="valueChange"
                    execute="@this"
                    render="nextActionPanel"/>
           </h:selectOneMenu>
            </h:panelGroup>
           <h:commandButton id="submit" value="Submit" render="@form"/><br/>
           <h:messages/>
            <ui:debug/>
    </h:form>
    </h:body>
    </html>All I changed was
    1) Added the following:
    Backing Bean value for nextAction is '<h:outputText value="#{viewBean.nextAction}"/>'<br/>.. which is in the same panel ( <h:panelGroup id="nextActionPanel"> ) as the <h:selectOneMenu>
    2) Changed the render attribute of the h:selectOneMenu so that instead of @none, it is now:
                   <f:ajax
                    event="valueChange"
                    execute="@this"
                    render="nextActionPanel"/>3) Repeated the same steps as before ... and after step [6]:
    3a) The h:outputText says:
    Backing Bean value for nextAction is ''3b) But the h:selectOneMenu still has the PEND option selected.

  • Unable to call Action Method of the Backing Bean

    I have created a jsf page with several tables and input text boxes. I also have the command button to submit the values to the backing bean but, the action method "saveBean()" is not being called
    Hear are the codes listed below listed
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    <%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
    <h:form id="myBioDataForm">
    <h:panelGrid columns="2" >
              <h:panelGroup  >
                   <h:outputLabel id="NameLabel" value="Name" style="font-size: medium"/>
              </h:panelGroup>
              <h:panelGroup >
                   <h:inputText id="NameTextBox" value="#{bioData.objBioDataVo.name}"/>
              </h:panelGroup>
              <h:panelGroup  >
                   <h:outputLabel id="DOBLabel" value="DOB" style="font-size: medium"/>
              </h:panelGroup>
              <h:panelGroup >
                   <t:inputCalendar id="DOBCalendar" renderAsPopup="true"  value="#{bioData.objBioDataVo.doB}"/>
              </h:panelGroup>
              <h:panelGroup  >
                   <h:outputLabel id="AddressLabel" value="address" style="font-size: medium"/>
              </h:panelGroup>
              <h:panelGroup >
                   <h:outputLabel value=""/>
              </h:panelGroup>
              <h:panelGroup  >
                   <h:outputLabel id="Street" value="Street" style="font-size: medium"/>
              </h:panelGroup>
              <h:panelGroup >
                   <h:inputText id="StreetTextBox" value="#{bioData.objBioDataVo.street}"/>
              </h:panelGroup>
              <h:panelGroup  >
                   <h:outputLabel id="City" value="Town/City" style="font-size: medium"/>
              </h:panelGroup>
              <h:panelGroup >
                   <h:inputText id="CityTextBox" value="#{bioData.objBioDataVo.city}"/>
              </h:panelGroup>
              <h:panelGroup  >
                   <h:outputLabel id="Pincode" value="Pincode" style="font-size: medium"/>
              </h:panelGroup>
              <h:panelGroup >
                   <h:inputText id="PincodeTextBox" value="#{bioData.objBioDataVo.pincode}"/>
              </h:panelGroup>
              <h:panelGroup  >
                   <h:outputLabel id="Mobile" value="Mobile" style="font-size: medium"/>
              </h:panelGroup>
              <h:panelGroup >
                   <h:inputText id="mobileTextBox" value="#{bioData.objBioDataVo.mobile}"/>
              </h:panelGroup>
              <h:panelGroup  >
                   <h:outputLabel id="Email" value="Email" style="font-size: medium"/>
              </h:panelGroup>
              <h:panelGroup >
                   <h:inputText id="emailTextBox" value="#{bioData.objBioDataVo.email}"/>
              </h:panelGroup>
              <h:panelGroup  >
                   <h:outputLabel id="Gender" value="Gender" style="font-size: medium"/>
              </h:panelGroup>
              <h:panelGroup >
                   <h:selectOneRadio value="#{bioData.objBioDataVo.gender}">
                        <f:selectItem itemLabel="Male" itemValue="Male"/>
                        <f:selectItem itemLabel="Female" itemValue="Female"/>
                   </h:selectOneRadio>
              </h:panelGroup>
              <h:panelGroup  >
                   <h:outputLabel id="Marital_Status" value="Marital Status" style="font-size: medium"/>
              </h:panelGroup>
              <h:panelGroup >
                   <h:selectOneRadio value="#{bioData.objBioDataVo.status}">
                        <f:selectItem itemLabel="Married" itemValue="Married"/>
                        <f:selectItem itemLabel="UnMarried" itemValue="UnMarried"/>
                   </h:selectOneRadio>
              </h:panelGroup>
    </h:panelGrid>
    <f:verbatim><br><br><br></f:verbatim>
         <h:dataTable var="item" value="#{bioData.al}">
              <h:column>
              <f:facet name="header" >
                   <h:outputText value="No Of Years"/>
              </f:facet>
                   <h:selectOneMenu id="NoYears1" value="#{item.noYears}">
                   <f:selectItems value="#{item.noYearsVoTM}"/>
              </h:selectOneMenu>
              </h:column>
              <h:column>
              <f:facet name="header" >
                   <h:outputText value="Organisation"/>
              </f:facet>
                   <h:inputText id="OrgnisationTextBox" value="#{item.orgVo}"/>
              </h:column>
              <h:column>
              <f:facet name="header" >
                   <h:outputText value="Designation"/>
              </f:facet>
                   <h:inputText id="designationTextBox" value="#{item.desigVo}"/>
              </h:column>
         </h:dataTable>
                   <h:commandButton id="addRow" type="submit" value="Add Row" immediate="true" action="#{bioData.addStr}"/>
                   <h:dataTable  var="edual" value="#{bioData.eduList}">
              <h:column>
              <f:facet name="header" >
                   <h:outputText value="Year of Passing"/>
              </f:facet>
                   <h:selectOneMenu id="NoYears11" value="#{edual.yearPassing}">
                   <f:selectItems value="#{edual.yearPassingTM}"/>
              </h:selectOneMenu>
              </h:column>
              <h:column>
              <f:facet name="header" >
                   <h:outputText value="Qualification"/>
              </f:facet>
                   <h:selectOneMenu id="NoYears11" value="#{edual.qualification}">
                   <f:selectItems value="#{edual.qualificationTM}"/>
              </h:selectOneMenu>
              </h:column>
              <h:column>
              <f:facet name="header" >
                   <h:outputText value="Specialisation"/>
              </f:facet>
                   <h:inputText id="SpecialisationTextBox1" value="#{edual.specialisation}"/>
              </h:column>
              <h:column>
              <f:facet name="header" >
                   <h:outputText value="Specialisation"/>
              </f:facet>
                   <h:inputText id="SpecialisationTextBox1" value="#{edual.specialisation}"/>
              </h:column>
              <h:column>
              <f:facet name="header" >
                   <h:outputText value="School"/>
              </f:facet>
                   <h:inputText id="SchoolTextBox1" value="#{edual.school}"/>
              </h:column>
              <h:column>
              <f:facet name="header" >
                   <h:outputText value="Total Marks"/>
              </f:facet>
                   <h:inputText id="MarksTextBox1" value="#{edual.cgpa}"/>
              </h:column>
         </h:dataTable>
                   <h:commandButton id="addRow1" type="submit" value="AddRow" immediate="true" action="#{bioData.addEdu}"/>
         <h:dataTable var="str" value="#{bioData.strList}">
              <h:column>
              <f:facet name="header" >
                   <h:outputText value="sno"/>
              </f:facet>
                   <h:inputText id="snoTextBox" value="#{str.sno}"/>
              </h:column>
              <h:column>
              <f:facet name="header" >
                   <h:outputText value="Stengths"/>
              </f:facet>
                   <h:inputText id="StengthsTextBox" value="#{str.strengths}"/>
              </h:column>
              <h:column>
              <f:facet name="header" >
                   <h:outputText value="Weaknesses"/>
              </f:facet>
                   <h:inputText id="WeaknessesTextBox" value="#{str.weaknesses}"/>
              </h:column>
         </h:dataTable>
                   <h:commandButton id="addRow2" type="submit" value="Add Row" immediate="true" action="#{bioData.addWks}"/>
              <h:outputLabel id = "saveLabel" value="Enter Name"/>
              <h:inputText id="saveTextBox" value="#{bioData.bioName}"/>     
              <h:commandButton id="savebutton" type="submit" value="Save"  action="#{bioData.saveBio}"/>
    </h:form>----------------------------Backing Bean--------------------------------------
    package com.minerva.trainees;
    import java.util.HashMap;
    public class BioDataHomeBackingBean
         String selectBio;
         HashMap selectBioHM;
         public BioDataHomeBackingBean() {
              selectBioHM = new HashMap();
              selectBioHM.put("Create BioData", "Create BioData");
         public String processBioData()
              String select_tmp = getSelectBio();
              String action="";
              if(select_tmp.equalsIgnoreCase("Create BioData"))
                   action= "displayCompetency@rgsRequest";
              return action;
         public String saveBio() throws Exception
              System.out.println("########################Inside saveBio##################");
              return "success";
         public String getSelectBio() {
              return selectBio;
         public void setSelectBio(String selectBio) {
              this.selectBio = selectBio;
         public HashMap getSelectBioHM() {
              return selectBioHM;
         public void setSelectBioHM(HashMap selectBioHM) {
              this.selectBioHM = selectBioHM;
    managed-bean>
              <managed-bean-name>MyNameBB</managed-bean-name>
              <managed-bean-class>com.minerva.trainees.MyNameBackingBean</managed-bean-class>
              <managed-bean-scope>session</managed-bean-scope>
         </managed-bean>
         <managed-bean>
              <managed-bean-name>bioData</managed-bean-name>
              <managed-bean-class>com.minerva.trainees.BioDataBackingBean</managed-bean-class>
              <managed-bean-scope>session</managed-bean-scope>
         </managed-bean>
         <managed-bean>
              <managed-bean-name>bioDataHome</managed-bean-name>
              <managed-bean-class>com.minerva.trainees.BioDataHomeBackingBean</managed-bean-class>
              <managed-bean-scope>session</managed-bean-scope>
         </managed-bean>
              <managed-bean>
              <managed-bean-name>bioTest</managed-bean-name>
              <managed-bean-class>com.minerva.trainees.TestBean</managed-bean-class>
              <managed-bean-scope>application</managed-bean-scope>
         </managed-bean>
              <managed-bean>
              <managed-bean-name>objBioDataVo</managed-bean-name>
              <managed-bean-class>com.minerva.trainees.BioDataVo</managed-bean-class>
              <managed-bean-scope>session</managed-bean-scope>
         </managed-bean>Please help me to solve this problem

    tracemein wrote:
    but, the action method "saveBean()" is not being called Maybe there was a validation or conversion error occurred. Add <h:messages /> to your page to take note of them and handle accordingly. Also read the application server logs if there isn't something interesting logged. JSF 1.2 by default logs undisplayed errors to the stdout.
    On the other hand, apart from the problem, you don't need h:panelGroup for single column items. Basically you can remove all of those h:panelGroup tags in your first h:panelGrid.

  • How to get a value for Select One Choice in the backing bean

    Friends,
    Does any one have any idea, how to get the value of a selected item value from the Select One Choice component in the backing bean iin valueChangeListener method. Right now I am always getting the sequence of the selected item, instead the actual selected value. I tried using 'ValuePassTrhough=true' also.. but didn't help
    Below is the my code snippet
    <af:selectOneChoice value="#{bindings.country.inputValue}"
    required="#{bindings.country.hints.mandatory}"
    shortDesc="#{bindings.country.hints.tooltip}"
    id="soc1" autoSubmit="true" valuePassThru="true"
    valueChangeListener="#{pageFlowScope.Bean.onValueChange
    <f:selectItems value="#{bindings.country.items}" id="si2"/>
    </af:selectOneChoice>
    Thanks in advance.

    check my other post at Re: Pass data from a variable to another page

  • How to get the value of a checkbox in the backing bean

    How to get the valaue of a checkbox in the backing bean?

    Hi this may help you for selecting single check box
    <h:outputText value="Enabled : "/>
                              <h:selectBooleanCheckbox value="#{Bean.isEnabled}"/>                    
                              <h:commandButton value="Submit" action="#{Bean.submit}"/>
    private Boolean isEnabled;
        public Boolean getIsEnabled() {
            return isEnabled;
        public void setIsEnabled(Boolean isEnabled) {
            this.isEnabled = isEnabled;
        public String submit(){
         System.out.println(isEnabled);
            return isEnabled;
        }for selecting multiple check box
                              <h:selectManyCheckbox value="#{Bean.items}">
                                  <f:selectItem itemLabel="one" itemValue="one" />
                                  <f:selectItem itemLabel="two" itemValue="two" />
                                  <f:selectItem itemLabel="three" itemValue="three" />
                               </h:selectManyCheckbox>
                   <h:commandButton value="Submit" action="#{Bean.submit}"/>
    private List<String> items;
        public List<String> getItems() {
            return items;
        public void setItems(List<String> items) {
            this.items = items;
        public String submit(){
            System.out.println("List : " + this.items);
            return "done";
        }Hope this helps you

  • Is there a way to get a (return) value back after running Javascript statements in the backing bean?

    I have a usecase  where I need to run a javascript function from within the backing bean and get the value returned by the function.
    Example:
              In Java I have two variables  x and y, I want the javascript to return the larger value z.
              This is what I'm doing, but I have no means to get the values of variable z.
              StringBuilder script = new StringBuilder();
              script.append("var  z;");
              script.append("var  x = " + x + ";");
              script.append("var  y = " + y + ";");
              script.append("if  (x > y)  z = x  else z = y");
              FacesContext fctx = FacesContext.getCurrentInstance();
              ExtendedRenderKitService erks = Service.getRenderKitService(fctx,
              ExtendedRenderKitService.class); erks.addScript(fctx, script);
         The actual usecase is a bit complicated. It's a dragNdrop paradigm.
         I cannot capture the muse Release event (DropEvent ?) in the client side as (most likely) it is captured by ADF.
         The drop target is a RichTextEditor. I need to convert the DropEvent.getDropX() and DropEvent.getDropY() to get the caret position in the text editor.
    Any other solution to the issue is highly appreciated.
    Thanks,
    -ab

    you can try it!
    erks.addScript(fctx, js_funcation_name("'"+x+"'","'"+y+"'","'"+x+"'","'"+x+"'",.....));//bean-> javaScript
    add javascript:
                   AdfCustomEvent.queue(p, 'XXXXX', {parameter:parameter_value},true);
    add:
    <af:serverListener type="XXXXX" method="#{ManageBean.funcation}"/>//js->bean

  • How to give the radio button value dml statement

    Oracle Forms6i
    Hai All
    I have created a form I the form i have created two radio button and named as appr, Recmd when i execute the forms appr is marked by default
    So now i need to insert or update this radio button value in my Table
    how can i insert or update this radio button value
    pls tell me the steps to do
    Thanks In Advance
    Srikkanth.M

    Hi,
    :<your_radiogroup_name> will give the selected radiobutton value

  • Calling a method in the backing bean when rendering a table

    I'm rendering a table that begins with :
    <h:dataTable value="#{showRooms.rooms}" var="rowRoom" ...
    There are several properties I'm displaying. Some are just displayed as they appear from the database like:
    <h:outputText value="#{rowRoom.roomNumber}"/>
    However, some I need to translate so they display a more meaningful message to the users. For example, status is stored 'A', or 'NA', but this should display 'Available' or 'Not Available'. To do this, I'm taking an idea I saw in another forum by providing a method to call and translate the text. For example:
    public String getDisplayedStatus(String status) {
    if (status.equals("A") {
    return "Available";
    } else {
    My problem is how can I invoke a method and pass in the current value of status for that row in the table. I think I need something like this:
    <h:outputText value="#{showRooms.getDisplayedStatus(#{rowRoom.roomStatus})"/>
    But that doesn't work. I can invoke the getDisplayedStatus method when passing in a hardcoded parameter, but it won't translate the value of both expressions(the method and the method param). How can I achieve this?
    Thanks,
    Mike

    Yes. I've done that and it does work....sort of. It works as long as I refer to it as 'displayStatus'. It looks up the getDisplayStatus and returns a value. The problem is getting the current status value from the object in the List. For example, the 3rd row in the table has either 'A;' or 'NA' for status. I need to know this value in order to do my translation. The way I see it, I either need
    1.)a way to call a method on the backing bean and pass the value of status from the current row into the method.
    -or-
    2.)in getDisplayStatus, I need a way to access the current row's value, perhaps through an expression. This appears to be what you can do in the AbstractPageBean class that all backing beans inherit in Studio Creator. I've seen code in a getter like 'getValue(#{currentRow.status}'), but I don't know how that is done. I looked for the source to AbstractPageBean on the web but couldn't find it - maybe its not open-source.
    Anyway, please share if anyone has a solution. I'm sure this has been done before.
    Thanks,
    Mike

  • How to pass radiio button value

    Hi All,
    I have two pages PAGE A, PAGE B.
    In page A, I have two radio buttons Yes and no.I'm populating this through database data.
    Here is my problem, when I change the radio button, the changed value is not passing to PAGE B.
    Can anybody tell me how to do this ?
    I know how to pass the value, if I don't populate data from the database....beca'z I can put the radio button value as "yes"or"no".
    but if i use variable in the radio button "value" then I'm not able to pass the value...
    can you please help me on this ?

    Please post an SSCCE (i.e., the minimum amount of correct code) that demonstrates the problem.
    ~

  • To Retrieve dynamic radio button values using jsp & javascript

    Hi All,
    How can i retrive the dynamically created radio button values and also want to get the clicked radio button values.I am using JSP and JAVA beans to retrive the values from the form. I dont have any probs to retrieve combo box values, text box values only problem showing with radio button values. If any data which is entered wrong in the form all the fields should prefills with the old value.Except radio button values all others fields such as combo box, text box values are prefilled with the old values.
    I have given the code for radios.
    document.write('<input type="radio" name="distradio" OnClick="sampleReq.fcidis.value=\'Y\'"/>Yes   ');
    document.write('<input type="radio" name="distradio" OnClick="sampleReq.fcidis.value=\'N\'"/>No');
    document.write('<input type="hidden" name="fcidis" value="">')
    <form method="POST" action="Update.jsp" name="sampleReq" >
    <tr>
    <td class="Txt_gris">
    <input type="radio" name="requester" OnClick="sampleReq.requester1.value='supplier'"/> supplier
    </td>
    <td class="Txt_gris">
    <input type="radio" name="requester" OnClick="sampleReq.requester1.value='customer'"/>customer
    </td>
    <td class="Txt_gris">
    <input type="radio" name="requester" OnClick="sampleReq.requester1.value='distributor'"/> distributor
    </td>
    <td class="Txt_gris">
    <input type="radio" name="requester" OnClick="sampleReq.requester1.value='employee'"/> employee
    </td>
    <td class="Txt_gris">
    <input type="radio" name="requester" OnClick="sampleReq.requester1.value='New partner'"/>New partner
    <input type="hidden" name="requester1" value=""/>
    </td>
    </tr>
    Advanced Thanks for help
    Regards
    Sona

    Hi,
    If you have this code
    document.write('<input type="radio" name="distradio" OnClick="sampleReq.fcidis.value=\'Y\'"/>Yes ');
    document.write('<input type="radio" name="distradio" OnClick="sampleReq.fcidis.value=\'N\'"/>No');
    document.write('<input type="hidden" name="fcidis" value="">')
    <form method="POST" action="Update.jsp" name="sampleReq" >
    <tr>
    <td class="Txt_gris">
    <input type="radio" name="requester" OnClick="sampleReq.requester1.value='supplier'"/> supplier
    </td>
    <td class="Txt_gris">
    <input type="radio" name="requester" OnClick="sampleReq.requester1.value='customer'"/>customer
    </td>
    <td class="Txt_gris">
    <input type="radio" name="requester" OnClick="sampleReq.requester1.value='distributor'"/> distributor
    </td>
    <td class="Txt_gris">
    <input type="radio" name="requester" OnClick="sampleReq.requester1.value='employee'"/> employee
    </td>
    <td class="Txt_gris">
    <input type="radio" name="requester" OnClick="sampleReq.requester1.value='New partner'"/>New partner
    <input type="hidden" name="requester1" value=""/>
    </td>
    </tr>
    this field distradio will not be able Update.jsp.
    You will need to insert these field into the form definition.
    Now, to get a valeu from a radio button, you need only to do request.getAttribute("fieldName").
    To generate dinamically all radio button values, i need to know where are these information? In database? If yes, you need to read the resultset na in value attribute you need to do somethink like this <input type=radio name=fieldName value="<%out.println(resultset.getString("FieldName"));%>">
    If you have more question, only send me a email,
    best regards
    Edney Imme
    [email protected]

  • How to call the backing bean method through javascript by closing window?

    Hi all,
    What I want to do is:
    I open a new page by clicking <t:commanLink.../> from the first page. Then I close the new page. By closing the new page I will call a function in the backing bean such as myBean.doSomething() to do something. Such like:
    <body onUnload=jsFunction()..../>
    ...

    So far I understand, I should write following code
    in my second page:
    <html>
    <head>
    <script type="txet/javascript">
    function jsFunction()
    {>
    ocument.forms[0].action="#{myBean.doSomething}";
    document.forms[0].submit();
    </scrip>
    </head>
    <body onunload="jsFunction()">
    <ui:composition>
    <h:form id="myForm">
    <t:commandLink id="myLink" immediate="true"
    action="#{myBean.doSomething}"
    value=""></t:commandLink>
    </h:form>
    </ui:composition>
    Is that right? I am not sure if I've the javascript
    in the right position.I am sorry! That solution will not work. My Bad.
    You can try this.
    1) Have a invisible command button on your first page with the action attribute set to "#{myBean.doSomething}" as below
    <t:commandButton style="width:0px;height:0px" id="myButton" immediate="true"
    action="#{myBean.doSomething}"
      value=""></t:commandButton>2) Your JS onunload method on the second page should look like
    <script type="txet/javascript">
       function jsFunction()
    var buttonObject= window.parent.document.getElementById("formname:myButton");
    buttonObject.click(); // This would help in submitting the first page
    // to submit to the needed action method
    </script>Karthik

  • H:inputText ; How To initialize value Property from back/bean method?

    Hello Guys at Sun Forums.
    I am a newbie at using JSF. and I'm having a bit of a Problem.
    I don't know how to initialize the value property of a h:inputText from a method inside a backing bean that returns a String data type.
    My Method inside the Backing bean is this:
    public String getLastDate()
            Connection con = null;
            Statement stmt = null;
            ResultSet rs = null;
            Date DateCapt = null;
            String DateConv= null;
            try{
                Class.forName("com.sybase.jdbc2.jdbc.SybDrive").newInstance();
                con = DriverManager.getConnection("jdbc:sybase:Tds:localhost/BAN_PRO_SNP", "xxxx", "xxxx");
                if(!con.isClosed()){
                    stmt = con.createStatement();
                    stmt.executeQuery ("SELECT TOP 1 CONVERT(VARCHAR(10), fec_parametro, 103) fec_parametro FROM snp_sei_parametros" +
                    "     WHERE cod_parametro = 'FECHA'" +
                    "     ORDER BY fec_parametro DESC");
                    rs = stmt.getResultSet();
                    while (rs.next())
                                DateCapt = rs.getDate("fec_parametro");
                rs.close();  
                stmt.close(); 
            catch (Exception ex)
                        System.out.println("COULD NOT LOAD THE DRIVER!!!!");
                        System.out.println(ex);
                    DateConv = String.valueOf(DateCapt).toString();
        return DateConv;
    }As you can see the Method returns a String data type, and all I want to know is how put that returned String as the initial value of a h:inputText. when the jsf-jsp page loads.
    Please Help Me.

    You should be able to do
       <h:inputText value="#{bean.lastDate}"/>Where 'bean' is the managed bean name containing
    the method getLastDate().
    When the view is rendered, the getter (getLastDate())
    will be called to display whatever value is returned.

  • When radio button is enabled the block should be enable

    I have a 4 radio buttons and a four blocks in a same single canvas , and when ever i enable a radio button the related block should get enable .. pls help me with coidng

    Use the when-radio-changed trigger. There is a RADIO BUTTON VALUE property per radio item. You can place in the trigger...
    IF CONTROL.TEMP_RADIO_BUTTON = 1 THEN
    SET_BLOCK_PROPERTY ('BLOCK1', ENABLED, PROPERTY_TRUE);
    ELSIF...
    END IF;
    Hope this helps...

  • Add UIComponents to the page via the backing bean

    Is it possible to add a UIComponent to my page (Page1.jsp) from the backing bean (Page1.java)?
    For example:
    public class Page1 extends AbstractPageBean {
      public Page1() {
        HtmlPanelGroup panel = new HtmlPanelGroup();
        this.page.getChildren().add(panel);  //<-- doesn't work
    }

    Hi Lexicore:
    I'm new to JSF and tried to utilize your example - with no success (see below)...
    I assume I took your suggestion to literally.
    Please tell me what is missing.
    ****jsp page: jsp1.jsp****
    <%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <html>
    <f:view>
    <head>
    <title>jsp1</title>
      <link rel="stylesheet" type="text/css" href="./style.css" title="Style"/>
    </head>
    <body bgcolor="#ffffff">  TESTING...
      <h:form id="form1">
        <h:panelGrid id="panelgridtest" binding="#{jsp1Bean.component}"/>
      </h:form>
    </body>
    </f:view>
    </html>
    ****backing bean: "Jsp1Bean.java" ****
    package test;
    import javax.faces.application.*;
    import javax.faces.component.*;
    import javax.faces.component.html.*;
    import javax.faces.context.*;
    import javax.faces.el.*;
    public class Jsp1Bean
        protected UIComponent component;
        public Jsp1Bean()
            component = new UIPanel();
        public UIComponent getComponent()
            return component;
        public void setComponent(UIComponent component)
            this.component = component;
    //initialization block
            try
                FacesContext facesContext = FacesContext.getCurrentInstance();
                UIViewRoot uIViewRoot = facesContext.getViewRoot();
                Application application = facesContext.getApplication();
    //outputText1
                HtmlOutputText outputText1 = (HtmlOutputText) facesContext.getApplication().createComponent(HtmlOutputText.COMPONENT_TYPE);
                outputText1.setValue("---the outputText1 value---");
    //inputText1
                HtmlInputText inputText1 = (HtmlInputText) facesContext.getApplication().createComponent(HtmlInputText.COMPONENT_TYPE);
                inputText1.setValue("---the inputText1 value---");
    //add outputText1 and inputText1 to component ("UIPanel")
                component.getChildren().add(outputText1);
                component.getChildren().add(inputText1);
            catch (java.lang.Throwable t)
                System.out.println("java.lang.Throwable exception encountered...t.getMessage()=" + t.getMessage());
                t.printStackTrace();
        public String doAction()
            return "submit";
    ****faces-config.xml****
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN" "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
    <faces-config>
      <navigation-rule>
        <from-view-id>/jsp1</from-view-id>
        <navigation-case>
          <from-action>submit</from-action>
          <to-view-id>/jsp1</to-view-id>
          <redirect/>
        </navigation-case>
      </navigation-rule>
      <managed-bean>
        <managed-bean-name>jsp1Bean</managed-bean-name>
        <managed-bean-class>test.Jsp1Bean</managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
      </managed-bean>
    </faces-config>
    **** Error Message I receive from trying to run ****
    Nov 5, 2004 5:05:03 PM org.apache.catalina.core.StandardHostDeployer install
    INFO: Installing web application at context path /test from URL file:C:\tomcat\webapps\test
    Nov 5, 2004 5:05:09 PM org.apache.catalina.core.StandardHostDeployer install
    INFO: Installing web application at context path /tomcat-docs from URL file:C:\tomcat\webapps\tomcat-docs
    Nov 5, 2004 5:05:09 PM org.apache.catalina.core.StandardHostDeployer install
    INFO: Installing web application at context path /webdav from URL file:C:\tomcat\webapps\webdav
    Nov 5, 2004 5:05:10 PM org.apache.coyote.http11.Http11Protocol start
    INFO: Starting Coyote HTTP/1.1 on http-8084
    Nov 5, 2004 5:05:10 PM org.apache.jk.common.ChannelSocket init
    INFO: JK2: ajp13 listening on /0.0.0.0:8012
    Nov 5, 2004 5:05:10 PM org.apache.jk.server.JkMain start
    INFO: Jk running ID=0 time=15/234  config=c:\tomcat\conf\jk2.properties
    Nov 5, 2004 5:05:10 PM org.apache.catalina.startup.Catalina start
    INFO: Server startup in 16656 ms
    java.lang.Throwable exception encountered...t.getMessage()=null
    java.lang.NullPointerException
            at test.Jsp1Bean.<init>(Unknown Source)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
            at java.lang.Class.newInstance0(Class.java:308)
            at java.lang.Class.newInstance(Class.java:261)
            at java.beans.Beans.instantiate(Beans.java:204)
            at java.beans.Beans.instantiate(Beans.java:48)
            at com.sun.faces.config.ManagedBeanFactory.newInstance(ManagedBeanFactory.java:204)
            at com.sun.faces.application.ApplicationAssociate.createAndMaybeStoreManagedBeans(ApplicationAssociate.java:253)
            at com.sun.faces.el.VariableResolverImpl.resolveVariable(VariableResolverImpl.java:78)
            at com.sun.faces.el.impl.NamedValue.evaluate(NamedValue.java:125)
            at com.sun.faces.el.impl.ComplexValue.evaluate(ComplexValue.java:146)
            at com.sun.faces.el.impl.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.java:243)
            at com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:173)
            at com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:154)
            at com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:389)
            at javax.faces.webapp.UIComponentTag.createComponent(UIComponentTag.java:1018)
            at javax.faces.webapp.UIComponentTag.createChild(UIComponentTag.java:1045)
            at javax.faces.webapp.UIComponentTag.findComponent(UIComponentTag.java:742)
            at javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:423)
            at com.sun.faces.taglib.html_basic.PanelGridTag.doStartTag(PanelGridTag.java:442)
            at org.apache.jsp.jsp1_jsp._jspx_meth_h_panelGrid_0(jsp1_jsp.java:152)
            at org.apache.jsp.jsp1_jsp._jspx_meth_h_form_0(jsp1_jsp.java:131)
            at org.apache.jsp.jsp1_jsp._jspx_meth_f_view_0(jsp1_jsp.java:101)
            at org.apache.jsp.jsp1_jsp._jspService(jsp1_jsp.java:62)
            at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
            at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
            at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)

  • How to track PropertyChangeEvent for the backing beans?

    Hello
    I'm working on JSF 1.2 + JDK 1.6. Would like to know wether any direct support for tacking the PropertyChangeEvent for the backing bean. Objective is to keep track of the modified entities ( backing bean) and update the corresponding Database records at later stage with the modified attribute/record.
    E.g:
    Assume a datatable is populated with list, and 3 rows alone is modified, So the DB update is supposed to happen only for those rows. I prefer to have the PropertyChange tracking logic in one place. Dont want to add PropertyChangeListener for all backing beans.
    Can anybody help me on this.
    Thanks in advance
    Jobinesh
    Edited by: JobineshP on Jun 20, 2008 6:52 AM

    This is no direct support in JSF for PropertyChangeEvents.
    As for other solutions to your problem, first looking specifically at the database updates, Hibernate tracks modifications to fields and can be configured to only update the needed columns (see the dynamic-update attribute). So perhaps Hibernate can suit your needs or you could use their techniques to solve your problem.
    Taking a wider view of the general problem of adding PropertyChangeListeners to managed beans, I would be inclined to use Spring and AOP to add the PropertyChangeEvents to all the setters. Spring might also help the configuration of the PropertyChangeListeners. Although I have to say that I think that PropertyChangeEvents are of limited use in a web application.
    Another approach might be to hook into the JSF EL expression engine. You could add a special ELResolver whose purpose is to discover when the property changes happen. The drawback is that all the setting must be done via the EL in order for this to work.

Maybe you are looking for