Applying viewcriteria inside the backing bean

Hi Experts,
Currently i am building one table based on the View object. In that view object i have an attribute which returns true or false.
My requirement in the page i need to have a check box and if the user selects the check box then i need to show the records where the attribute is true. In case of check box deselection then i need to show all the entries (please note not the entries where the attribute value is false)
So i have created one view criteria in the view object and handled the checked box selection inside my backing bean. However it seems the criteria is not apply to the model. Any idea? or any other way i can implement this.
Apart from this i tried the checked box inside the column filter facet. However the issue is if check box is selected then that filters only true entries. deselected then the false entries. If i use the drop down list then i can implement my requirement without any issue.
-t
here the code segment
DepartmentVOImpl securityCompVO =
(DepartmentVOImpl )findDataControl("ManageDepartmentAMDataControl").getApplicationModule().findViewObject("DepartmentVO1");
if (selected) {
//Apply the criteria
ViewCriteria criteria =
departmentVO.getViewCriteriaManager().getViewCriteria("DepartmentVOCriteria");
criteria.setProperty(ViewCriteriaHints.CRITERIA_AUTO_EXECUTE, Boolean.TRUE);
departmentVO.applyViewCriteria(criteria);
departmentVO.executeQuery();
} else {
//remove the criteria
departmentVO.removeApplyViewCriteriaName("DepartmentVOCriteria");
departmentVO.executeQuery();
Util.refreshComponent(richTable);

User,
I would personally not like this code.
You should not get access to the AM in the view layer.
What i would advice you to do is from your backing bean call an AM service method passing the checkbox value (selected or not) . In the Service method get access to the VO and then apply the viewcritera using VO.setApplyViewCriteria() and finally reexecute the VO.

Similar Messages

  • 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 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

  • 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 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 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.

  • How to get specific rows from the vo or Iterator in the backing bean?

    Hi,
    I have to get the specific number of rows from iterator in the backing bean. means i want to get the records from the VO or Iterator only from 5 th record to 10th record its like rownum in SQL.
    We can use rownum in VO sql query. but there would be a performance issue with that ...
    SO i am trying to get the rows from ADF Iterator once we fetch from DB.
    Is it possible to do that ?
    Do we have any way to set the pointer to the VO/Iterator like setFirst() and after that setMaxResult to retrun the rows between first and maxresult..
    Thanks

    If this is for pagination, then af:table offers pagination by design when you set accessmode=RangePaging or RangePagingIncremental in VO. Paginated queries are fired when scroll down in the table. Explore this option before you try out any custom solution
    To answer the question,
    Note: same logic i have implpemented ADF with EJB ..In EJB Query class we have setFirst(int) and setMaxResult(int) methods...simply i did setFirst(30) and setMaxResult(10)..It worked fine...Theoretically speaking the same can be achieved by setting setRangeStart() on the viewobject(which in turn sets to the default rowset) and by setting max fetch size on VO + accessmode=RangePaging. However when you use table with ADF binding, these will be overridden by the binding layer. If you are not using ADF binding, then the above is same as what you did for JPA entity. Other option is, you build expert mode VO with rownum for this special case, which will work if you dont need to set accessmode=RangePaging for VO.

  • 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.

  • 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

  • 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)

  • Build a ui component from the backing bean 2

    This is a related question to one I just posted:
    So, I'm trying to build ui components programmatically. In particular, I'm tyring to build af:selectBooleanCheckBox(es), using af:foreach loop. However, to know how many to output I need some information from the database. I query the database in the application module and build an array from the resulting query. I return this array from my method. Now in my backing bean, I want to invoke this method so I can get the array. I'll use tihs array in my jsp page to output the UI component. When I try to instantiate the function in the constructor of my backing bean, I get an error. So I'm planning to use invokeAction to run my method automatically on page load. However, if I do this, how do I get back my array? Where is it stored?
    Also, is it possible to make my array available to my jsp page without going through my backing bean?
    Thanks in advance.

    Hi, it would help if you tell us the jdev version you are using. I assume you use adf rich faces?
    As a general rule, you can't put this kind of code in the constructor.
    I would use a bounded task flow and put call a bean method as default task inside it.
    Timo

  • How to call a query from the backing bean ?

    Hi all,
    Another question for you guys :
    I made a jspx page with an input form and a submit button.
    When I click the submit button, the action my_action in my backing bean is executed.
    This is the code :
    public BindingContainer getBindings() {
    return BindingContext.getCurrent().getCurrentBindingsEntry();
    public String my_action() {
    BindingContainer bindings = getBindings();
    OperationBinding operationBinding = bindings.getOperationBinding("EmployeesView");
    Object result = operationBinding.execute();
    if (!operationBinding.getErrors().isEmpty()) {
    return null;
    I hoped that the query 'EmployeesView' was executed in this way, but I get the following exception :
    java.lang.ClassCastException: oracle.adfinternal.view.faces.model.binding.FacesCtrlHierBinding cannot be cast to oracle.binding.OperationBinding
    So how should I execute the query EmployeesView ?
    Second part of the question : What if I typed the name an employee in my form, and I want to
    execute a query that selects all the Employees with that name ?
    How do I make a query with a variable as input in the WHERE clause ?
    Thanks in advance.
    Edited by: Facehugger on 7-apr-2010 11:15

    I'm still trying all the stuff you guys says, but still no result.
    This is my backing bean :
    +// the button action+
    +public String my_action()  {+ 
    +// get the selected rows from the multiselect table and store the objectid's in an String array+
    RowKeySet rks = graph_table.getSelectedRowKeys();
    Iterator itr = rks.iterator();
    Object key;
    int nbr_objects = 0 , i = 0;
    if (rks.size()>0)  nbr_objects = rks.size();
    +String[] objectid = new String[nbr_objects];+
    while(itr.hasNext())
    +{+
    key = itr.next();
    graph_table.setRowKey(key);
    Object o = graph_table.getRowData();
    JUCtrlHierNodeBinding rowData = (JUCtrlHierNodeBinding) o;
    Row row = rowData.getRow();
    +objectid[i] = row.getAttribute("Objectid").toString();+
    i+;+
    +}+
    +// now get all the x and y values for these objectid's from the database out of the table history.+
    BindingContainer bc = BindingContext.getCurrent().getCurrentBindingsEntry();
    for (int j=0 ; j<nbr_objects; j+){+
    +// get X and Y values for object number j+
    DataPoints history = new DataPoints();
    OperationBinding operationBinding = bc.getOperationBinding("retrieveHistory");   ===> operationBinding stays NULL ???+
    +operationBinding.getParamsMap().put("OBJECTID", objectid[j]);+
    Object retVal = operationBinding.execute();
    +// ==> retVal should contain a List of all X and Y values for the provided objectid.+
    +// while (retVal has values)+
    +// {+
    +// List_of_x_values.add(retVal.valueX);+
    +// List_of_y_values.add(retVal.valueY);+
    +// }+
    history.add(List_of_x_values);
    history.add(List_of_y_values):
    +// call the soap method to do some calculations+
    methodname.forecast(history);
    +}+
    +}+
    In my application module :
    public void retrieveHistory(String objectid) {
    getHistory().setWhereClause("OBJECTID = '" + objectid + "'");
    System.out.println("current query : "+getHistory().getQuery());
    getHistory().executeQuery();
    public ViewObjectImpl getHistory() {+
    return (ViewObjectImpl)findViewObject("History");+
    The query for the VO History : SELECT * FROM HISTORY
    Please anyone ?
    Edited by: Facehugger on 9-apr-2010 14:19

  • How to use sendRedirect jsp page to client in the backed bean

    Hi,
    i'm unable to sendRedirect the page in baking bean method it is throwing error as
    javax.servlet.ServletException: Cannot forward after response has been committed
    <h:selectOneMenu value="#{surveyList.actionValue}" onchange="submit();" valueChangeListener="#{authorHomeBean.onChangeActionType}">
                                                           <f:selectItems value="#{surveyList.actionValueListItems}" />
                                                      </h:selectOneMenu>
    public void onChangeActionType(ValueChangeEvent event)
              if(((String)event.getNewValue()).split("~")[0].equals("Edit Survey"))
                   System.out.println("inside the Edit Survey 1");
                   try
                        FacesContext context = FacesContext.getCurrentInstance();
                        HttpServletResponse res =(HttpServletResponse)context.getExternalContext().getResponse();
                        res.sendRedirect("/feedback/author/surveyinfo/surveyinfo.jsf");
                        catch(Exception e)
                        e.printStackTrace();
    it is giving error as
    javax.servlet.ServletException: Cannot forward after response has been committed
         javax.faces.webapp.FacesServlet.service(FacesServlet.java:121)
         org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:122)
         org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:174)
         org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    root cause

    else if(((String)event.getNewValue()).split("~")[0].equals("Copy"))
                   try
                        res.sendRedirect("/feedback/author/surveyinfo/copysurvey.jsf");
                        context.responseComplete();          
                   catch(Exception e)
                        e.printStackTrace();
    it is giving error like this, when i use session scope for one of the bean in my faces config..so i'm unable to sendRedirect the page..
    OpenSessionInViewFilter.getSession() invoked...
    OpenSessionInViewFilter.closeSession() invoked...
    OpenSessionInViewFilter.getSession() invoked...
    inside the Edit Survey 1
    java.lang.NullPointerException
         at org.apache.coyote.tomcat5.CoyoteResponse.toAbsolute(CoyoteResponse.java:1450)
         at org.apache.coyote.tomcat5.CoyoteResponse.sendRedirect(CoyoteResponse.java:1213)
         at org.apache.coyote.tomcat5.CoyoteResponseFacade.sendRedirect(CoyoteResponseFacade.java:357)
         at javax.servlet.http.HttpServletResponseWrapper.sendRedirect(HttpServletResponseWrapper.java:125)
         at stanford.gsb.app.feedback.view.bean.author.AuthorHomeBean.onChangeActionType(AuthorHomeBean.java:530)
         at jrockit.reflect.VirtualNativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown Source)
         at java.lang.reflect.Method.invoke(Ljava.lang.Object;[Ljava.lang.Object;I)Ljava.lang.Object;(Unknown Source)
         at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:129)
         at javax.faces.component.UIInput.broadcast(UIInput.java:200)
         at javax.faces.component.UIData.broadcast(UIData.java:338)
         at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:90)
         at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:143)
         at org.apache.myfaces.lifecycle.LifecycleImpl.processValidations(LifecycleImpl.java:240)
         at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:76)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:106)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
         at org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:122)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
         at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:174)
         at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
         at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
    OpenSessionInViewFilter.closeSession() invoked...                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How can I receive the value of a selected item in the backing bean

    I have a table in a jspx file.
    When I go to the detail page I want to do something with the value of the currentrow.
    I want do a calculaction of the value of ClbId.
    How can I receive the value of the selected ClbId in my backing bean
    <af:table value="#{bindings.Searchteamlist.collectionModel}"
    var="row" rows="#{bindings.Searchteamlist.rangeSize}"
    first="#{bindings.Searchteamlist.rangeStart}"
    emptyText="#{bindings.Searchteamlist.viewable ? 'No rows yet.' : 'Access Denied.'}"
    selectionState="#{bindings.Searchteamlist.collectionModel.selectedRow}"
    selectionListener="#{bindings.Searchteamlist.collectionModel.makeCurrent}"
    rendered="#{backing_FirstFlag_Club_Club.searchFirstTimeClub_Club_AdresAndereClubs == false}">
    <af:column sortProperty="Matricule" sortable="true"
    headerText="#{bindings.Searchteamlist.labels.Matricule}">
    <af:outputText value="#{row.Matricule}"/>
    </af:column>
    <af:column sortProperty="ClbId" sortable="true"
    headerText="#{bindings.Searchteamlist.labels.ClbId}">
    <af:outputText value="#{row.ClbId}">
    <f:convertNumber groupingUsed="false"
    pattern="#{bindings.Searchteamlist.formats.ClbId}"/>
    </af:outputText>
    </af:column>
    <af:column sortProperty="Nom" sortable="true"
    headerText="#{bindings.Searchteamlist.labels.Nom}">
    <af:outputText value="#{row.Nom}"/>
    </af:column>
    <f:facet name="selection">
    <af:tableSelectOne text="Select and">
    <af:commandButton text="Submit"
    action="club_AdresAndereClubsDetail">
    <af:setActionListener from="#{row}"
    to="#{processScope.row}"/>
    </af:commandButton>
    </af:tableSelectOne>
    </f:facet>
    </af:table>

    hi tde
    Using an Expression Language helper class like this one from Steve Muench ...
    http://radio.weblogs.com/0118231/stories/2006/12/18/sourceForMyFavoriteElHelperClass.html
    ... you could write something like this in your backing bean:
    Integer vClbId = (Integer)EL.get("#{row.ClbId}");(Make sure to cast it to the correct type.)
    success
    Jan Vervecken

Maybe you are looking for

  • Issue in handlng context change

    Hi All, I have the following requirement : Consider for example there are 4 idocs sent from SAP ECC system . At the target end we have a segment called Records which repeats based on the number of times unique payment id exists. So , in the 4 IDOCs w

  • Applet: Null Pointer Exception in NN but not in IE???!!!!

    hi all, i have worked on a an applet that uses a nother Runnable class to implement an animated progress bar using MediaTracker, and i can control when to start animation and when to stop it! it worked great on IE. But when i came to test it on Netsc

  • Faulty audio line out

    The audio line out on my G5 dual-core has stopped working. There is a tiny amount of output, but not enough to drive the speakers. The headphone jack in front works. Does this mean the sound card is bad? The machine is less than one year old - should

  • Sharing Application Data Between 2 Web Services

    Hello, I have two web services that need to share data. They do not need to EXCHANGE data, but they need to have some sort of shared context to make the data available to each other. If its significant, one WS is jar-rs based, and the second is jax-w

  • Weblogic 11g on Windows - very slow admin server start

    Hello, It takes upwards of 15 minutes to fully start the admin server on my Windows box. I have read that it's a bug in the Java security random number/crypto api. There are various work arounds for the Linux environments, but no mention of Windows.