Throwing error from backing bean on button click?

Hi Everyone,
i have two lovs out of 2 lovs user has to select atleast one lov value and click on find button.
On clicking on find button im getting lov values if atleast one is not selected i need to throw one error message.
How can i throw error message?
Thanks.

Hi,
i used this code:
public String showMessage() {
System.out.println("inside error msg");
String messageText="Please select emp or ename";
FacesMessage fm = new FacesMessage(messageText);
* set the type of the message.
* Valid types: error, fatal,info,warning
//fm.setSeverity(FacesMessage.SEVERITY_INFO);
fm.setSeverity(FacesMessage.SEVERITY_ERROR);
FacesContext context = FacesContext.getCurrentInstance();
context.addMessage(null, fm);
System.out.println("end of error msg");
return null;
And called this method on clicking on find button in the method binding of the find button but it didnt show any error dialog bax rather it moved to the next page as usual.
Code in the find backing bean:
public String Find(){
if(Emp.equalsIgnoreCase("ALL") && EmpNo.equalsIgnoreCase("ALL")) {
String k=this.showMessage();
return "Find"; // to navigate to next page
what to do now?

Similar Messages

  • Set label of adf command button from backing bean

    How can we set the label of a command button from a backing bean using EL?
    Is it : <af: commandButton text="#{bindings.email.label}" action.....

    hi,
    create one string and generate accessor for it.
    then in jspx, like this
    text="#{PrintData.label}"
    you can have the label in this way from backing bean.
    private String label;
    public void setLabel(String label)
    this.label = label;
    public String getLabel()
    label = "test";
    return label;
    or else, through binding property of the command button, you can set it in the backing bean.
    hope this is useful for you.

  • Problem while invoking popup from backing bean

    I am invoking a popup from backing bean method.
    The same backing bean method has the business logic which depends on the data collected from popup(user enters some data on popup).
    So I need the business logic to be executed after popup comes up.
    The popup is coming after the execution of return statement in backing bean method . How do i make popup trigger at earlier point in the method.
    <af:commandToolbarButton text="#{corePostupgradeuiBundle.SIGN_OFF_MIG}"
    id="socb52"
    partialSubmit="true"
    actionListener="#{viewScope.signoffBean.signOffAgents}"
    partialTriggers="t3"/>
    public void signOffAgents(ActionEvent event) throws SQLException {
    DCBindingContainer bc =
    (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
    DCIteratorBinding summaryIter =
    bc.findIteratorBinding("Signoff1Iterator");
    showPopup("credentials"); //will get credential details from user and store in credential Bean
    //Following logic uses the data collected from popup
    EMCredentialReference credRef= credentialBean.getCredReference();
    submitJOb(credRef);
    public static void showPopup(String popupId) {
    FacesContext context = FacesContext.getCurrentInstance();
    StringBuilder script = new StringBuilder();
    script.append("AdfPage.PAGE.findComponent(\"").append(popupId).append("\").show();");
    ExtendedRenderKitService erks =
    Service.getService(context.getRenderKit(),
    ExtendedRenderKitService.class);
    erks.addScript(context, script.toString());
    UIComponent component = context.getViewRoot().findComponent(popupId);
    RequestContext.getCurrentInstance().addPartialTarget(component);
    }

    Well, your work flow is wrong.
    What you try to accomplish should work out of the box as
    1) user hit toolbar button
    2) this opens a popup "credentials" which have listeners for ok and cancel
    3) use fills in data in popup and hit ok or cancel
    4) one of the listeners gets fired
    5a) if OK listener you do your business logic
    5b) if cancel you do something else
    So all you have to do is the use a af:af:showPopupBehavioron the toolbar button, add a popup canel listener (if you need to act on canel) dependign on your popup design (dialog or simple button) add the appropriate listeners and in the listener method so your business logic.
    Timo

  • Few basic doubts about accessing AM from backing bean class

    Hi ADF experts,
    I have just started working in ADF Faces.I made a sample search page.My page is attached to a managed backing bean. I have attached command button on my page to a custom method in backing bean class.
    So on, click of button this method is called in backing bean.Now, i have few doubts:
    1)How to get values of various UI beans in this event code?
    2)I am accesing AM , in my method with this code:
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ExternalContext extContext = facesContext.getExternalContext();
    Application app = facesContext.getApplication();
    DCBindingContainer binding = (DCBindingContainer)app.getVariableResolver().resolveVariable(facesContext, "bindings");
    //Accessing AM
    ApplicationModule am = binding.getDataControl().getApplicationModule();
    iS this correct ?
    3) After getting handle of am how to call my custom method in AM Class?there was "invokeMethod" API in application module class in OAF, is there any such method here?
    Please help me.
    --ADF learner.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Thanks for ur response Frank, actually I am from OA Framework back ground.It would be great if help us a little with ur valuble thoughts.
    OA Framework also uses bc4j in model layer of framework. We have a requirement where our existing developers from OA Framework have to move to ADF to make a new application where time lines are quite strict.If this would not be possible we will switch to plain jsp and jdbc,but our tech experts say ADF Faces is the best tech.
    In OA Framework, Application Module is key class for all busiess logic and Controller is used for page navigation. So, I m just trying to find the same similarity , where we write we add all event codes in custom action methods in the backing bean class of page, which we consider equivalent to process form request method in Controller class of OAF.
    But there are two things, I still want to know:
    1)While page render, how to call specific AM methods(like setting where clause of certain VOs)
    2)In action methods, the way i described(I found that in one thread only)to access AM, what is wrong in that?Also, I went through
    http://radio.weblogs.com/0118231/stories/2004/09/23/notYetDocumentedAdfSampleApplications.html
    where coule of examples use similar approach to access AM from backing bean class and call custom methods of AM(Doing various, deletes etc from VOs).
    3)In these methods can we set any property of beans on the page, I am asking because in OAF, generally we use PPR for js alternatives.But all properties of beans cannot be set in post event.
    Thanks and Regards
    --ADF Learner                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Opening new browser window from backing bean

    Is it possible to open new window from backing bean?
    Regards, Simy

    quite sure its not possibleIt is possible !! But a fifferent way of doint it!
    I assume this is what you want ! on click of a button you want to go to the backing bean and come back with the new page on a new window !!
    Do the following! On click of a button, call a javascript method which does the following
    window.open('/jsf/somepage.jsf',.....)In the constructor of the backing bean, do the backend processing and set the fields of teh backing bean. And when the page gets rendered its as good as what you want...

  • How to show popup from backing bean code immediately?

    Hi,
    I'm using JDeveloper 11.1.2.1.0 and have problems with showing popups. I have a button with an action on my page and a method in backing bean.
    I want to rise up few popups from this method in backing bean (for example just an anouncement that something will happen) or a dialog
    (for example a question if you want to continue).
    I understand how to get a dialog response to deal with it in code, but the problem is that the popup doesn't show up immediately, but only when
    this method called on button finishes. I'd like to handle dialog responses in the middle of the action and then the code to continue with the execution.
    Here is my backing bean code:
    private RichPopup popup;
    public String test() {
    //Some code...
    RichPopup.PopupHints hints = new RichPopup.PopupHints();
    popup.show(hints);
    //Here is the place for code which I want to be executed after popup closes,
    //but is executed before the popup shows...
    return null;
    And here is part of my jssf:
    <af:commandButton text="Test" id="cb1"
    action="#{popupBean.test}"/>
    <af:popup id="popup" binding="#{popupBean.popup}">
    <af:dialog id="dialog" type="yesNo"
    title="Dialog"
    dialogListener="#{popupBean.onDialogAction}"
    binding="#{popupBean.dialog}" clientComponent="true">
    <af:outputText value="Do you want to continue?" id="ot1"/>
    <af:clientListener method="onDialogCancel" type="dialog"/>
    <af:serverListener type="DialogCancelHandlerEvent" method="#{popupBean.onDialogCancel}"/>
    </af:dialog>
    </af:popup>
    Can someone give me some answer how to show the popup from backing bean code immediately?
    Thanks in advance,
    Tina

    If you want to execute code after popup closes, then put this code in PopupCanceledListener or in DialogListener(you can't block method execution).
    Dario

  • Unable to execute javascript from backing bean

    Hello experts,  I want to execute  javascript function from backing bean method.   
    In my .jsff  page,  I have added  the javascript as :
    <jsp:root  ..... >
    <af:resource type="javascript" >
              function fileDownloadJS() {
                                alert(" tesing js from backing bean");
        </af:resource>
    </jsp:root>
    in my backing bean method  :
    public void callJSfuntion(ActionEvent actionEvent) {
            RenderKit rk = FacesContext.getCurrentInstance().getRenderKit();
            ExtendedRenderKitService erks = (ExtendedRenderKitService) Service.getService(rk, ExtendedRenderKitService.class);
            erks.addScript(context, "fileDownloadJS();");
    I have table in my .jsff page,   inside table column,  I have command link  and when I click the link,   I am invoking bean method  :
    <af:table  ....>
        <af:column sortProperty="title" sortable="true"  
                           headerText="File name" width="250px" id="Title"
                           clientComponent="true">
                  <af:commandLink   id="cl1"    actionListener="#{MyBean.callJSfuntion}" clientComponent="true">  
                    <af:outputText value="#{row.title}" id="ot1"/> 
                  </af:commandLink>
         </af:column>
    .</table>
    But when  I  run my taskflow and  click on  the link inside the table column,    JS function is not invoked.
    Absolutely  no clue what  is the issue.
    Appreciate if you can  help me out to resolve this issue.   Thank you.

    For debugging purpose can you try :
    <script type="javascript" >
              function fileDownloadJS() {
                                alert(" tesing js from backing bean");
    </script>
    put it on top of the page and let me know what happens.
    If it doesn't work try writing the function itself in your addScript(context, script); to see if it works.

  • Popup from backing bean not using facesContext.addMessage()

    I am creating a popup from backing bean as:
    FacesContext facesContext = FacesContext.getCurrentInstance();
    FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, null, "some message");
    facesContext.addMessage();
    I want the code after the popup creation to execute after the user clicks "ok" on the popup. But somehow the code after these lines gets executed first & then the popup appears after the control returns from the backing bean. Looks like the popup creation happens in a completely different thread. Is there a way to show the popup immediately where I want instead of this facesContext.addMessage() method where execution can wait for the user action?

    yeah, you can create a component declarative or popup that shows the message personalized, and call with javascript , see my others posts
    Re: Component Poppup declarative - problems with multiple instances
    this functional now with jdev 11.1.1.3.
    Regards
    joaquin

  • How can i call a taskflow methode from backing bean ??

    Build JDEVADF_11.1.1.3.PS2_GENERIC_100408.2356.5660
    i like to call a Methode (taskflow) from backing bean!
    my bean code :
        public void imageLinkActionListner(ActionEvent actionEvent) {
            String              id      = actionEvent.getComponent().getId();
            int                 linkID  = Integer.parseInt(id.substring(4));
            DCBindingContainer  bc      = (DCBindingContainer)ADFUtils.getBindingContainer();
            DCTaskFlowBinding   tf      = null;
            System.out.println("Region Change...."+id+" INT "+linkID);
            switch (linkID) {
                case LINK_CALENDAR_REGION:
                    tf = (DCTaskFlowBinding)bc.findExecutableBinding("calendartaskflowPage");                   
                break;
                case LINK_MAIL_REGION:
                    tf = (DCTaskFlowBinding)bc.findExecutableBinding("mailtaskflowPage");                   
                break;
              case LINK_ADDRESS_REGION:
                  tf = (DCTaskFlowBinding)bc.findExecutableBinding("addresstaskflowPage");                   
              break;
              case LINK_BLOGS_REGION:
                  tf = (DCTaskFlowBinding)bc.findExecutableBinding("blogstaskflowPage");                   
              break;
              case LINK_MAPS_REGION:
                  tf = (DCTaskFlowBinding)bc.findExecutableBinding("mapstaskflowPage");                   
              break;
            default:
                return;
            if (tf != null){
                uiMainRegion.setRegionModel(tf.getRegionModel());
                uiMainRegion.setValue(tf.getRegionModel());
                tf.getExecutableBindings();
                AdfFacesContext.getCurrentInstance().addPartialTarget(uiMainRegion);
        }i like to call *#{backingBeanScope.mapBean.initMap}*
    my taskflow source
    <?xml version="1.0" encoding="windows-1252" ?>
    <adfc-config xmlns="http://xmlns.oracle.com/adf/controller" version="1.2">
      <task-flow-definition id="map-task-flow">
        <default-activity id="__1">map</default-activity>
        <view id="map">
          <page>/map/map.jsff</page>
        </view>
        <method-call id="initMap">
          <method>#{backingBeanScope.mapBean.initMap}</method>
          <outcome id="__7">
            <fixed-outcome>init</fixed-outcome>
          </outcome>
        </method-call>
        <control-flow-rule id="__2">
          <from-activity-id id="__3">initMap</from-activity-id>
          <control-flow-case id="__5">
            <from-outcome id="__6">init</from-outcome>
            <to-activity-id id="__4">map</to-activity-id>
          </control-flow-case>
        </control-flow-rule>
        <use-page-fragments/>
      </task-flow-definition>
    </adfc-config>

    Hi,
    to call the bean, use the EL in Java and reference #{backingBeanScope.mapBean.initMap} as a method expression. If you try and access the bean directly then chances are that the instance is not available. Using EL from Java always guarantees this
    Frank

  • How to call a Javascript function from backing bean without any event

    Hi,
    Someone knows how to call a Javascript function from backing bean without any event ?
    thanks

    Please review the following thread:
    ADF Faces call javascript
    Luis.

  • Need to Add and Remove Columns of ADF Read Only table from Backing bean

    I have a scenario where I am trying to Populate TransientVO which is shown has a ADF Read Only Table in page.
    I have couple of Check Boxes Based on their selection I am trying to render and hide certain Columns.
    But the Issue which I am facing is only the Column Header seems to change where as the Rows and Values doesnt..
    even If I apply the expression language rendering condition on the outputText inside those columns.. ..
    So I am thinking to add and remove VO Attribute columns to the table from backing bean.
    Need some sample code snippet or a better design to achieve this. Its kind of urgent too...having an aggressive deadline :(
    Please chip in People..
    Thanks in Advance .
    TK

    Table Code..
    <af:table value="#{bindings.InventoryGridTrans.collectionModel}"
                                    var="row"
                                    rows="#{bindings.InventoryGridTrans.rangeSize}"
                                    emptyText="#{bindings.InventoryGridTrans.viewable ? 'No data to display.' : 'Access Denied.'}"
                                    fetchSize="#{bindings.InventoryGridTrans.rangeSize}"
                                    rowBandingInterval="0" id="t4"
                                    partialTriggers="::sbcSales ::sbcUsage ::cb1">
                            <af:column sortProperty="Period" sortable="false"
                                       headerText="#{bindings.InventoryGridTrans.hints.Period.label}"
                                       id="c38">
                              <af:outputText value="#{row.Period}" id="ot33"/>
                            </af:column>
                            <af:column sortProperty="Past12SalesCount"
                                       sortable="false"
                                       headerText="#{bindings.InventoryGridTrans.hints.Past12SalesCount.label}"
                                       id="c29"
                                       rendered="#{backingBeanScope.IndexPageBackingBean.onUsage != true and backingBeanScope.IndexPageBackingBean.onSales == true}">
                              <af:outputText value="#{row.Past12SalesCount}"
                                             id="ot40"
                                             rendered="#{backingBeanScope.IndexPageBackingBean.onUsage != true and backingBeanScope.IndexPageBackingBean.onSales == true}"
                                             visible="#{backingBeanScope.IndexPageBackingBean.onUsage != true and backingBeanScope.IndexPageBackingBean.onSales == true}">
                                <af:convertNumber groupingUsed="false"
                                                  pattern="#{bindings.InventoryGridTrans.hints.Past12SalesCount.format}"/>
                              </af:outputText>
                            </af:column>
                            <af:column sortProperty="Past12UsageCount"
                                       sortable="false"
                                       headerText="#{bindings.InventoryGridTrans.hints.Past12UsageCount.label}"
                                       id="c40"
                                       rendered="#{backingBeanScope.IndexPageBackingBean.onUsage == true and backingBeanScope.IndexPageBackingBean.onSales != true}"
                                       visible="#{backingBeanScope.IndexPageBackingBean.onUsage == true and backingBeanScope.IndexPageBackingBean.onSales != true}">
                              <af:outputText value="#{row.Past12UsageCount}"
                                             id="ot47"
                                             rendered="#{backingBeanScope.IndexPageBackingBean.onUsage == true and backingBeanScope.IndexPageBackingBean.onSales != true}"
                                             visible="#{backingBeanScope.IndexPageBackingBean.onUsage == true and backingBeanScope.IndexPageBackingBean.onSales != true}">
                                <af:convertNumber groupingUsed="false"
                                                  pattern="#{bindings.InventoryGridTrans.hints.Past12UsageCount.format}"/>
                              </af:outputText>
                            </af:column>
                            </af:column>
                    </af:table>

  • How can I set the value to a session bean from backing bean

    Hi Experts,
    How can I set the value to a session bean from backing bean where I have created getter and setter
    methods for that variable.
    Basically I am using ADFUtils class where I am able to get the value from session bean
    using following expression
    String claimType =
    (String)ADFUtil.invokeEL("#{ClaimValueObj.getClaimType}");
    Thanks
    Gayaz

    Gayaz,
    Wrong Post !!
    Post in JDeveloper and ADF
    Thanks
    --Anil                                                                                                                                                                                                                               

  • Calling function from Backing Bean or JSP page

    We are on Jdeveloper 10.1.3.3.0, ADF Faces, JSF Faces .., Currently there is a function call from Javascript event (onmouseover) in the JSP page. I want to call this function from a backing bean or JSP page, as I have to pass some values to this function.
    For Ex., I have a function call like return submit('A','B','Test'); on the Javascript event (onmouseover) in jsp page. I want to remove this function from the javascript event and call from backing bean or jsp page to pass some values into the submit() function. I appreciate if anyone can give some example of how to call this function from backing bean or jsp page in the <SCRIPT> or <SCRIPTLET>
    Thanks,
    Ram

    A use case would be helpful so that we can get a better idea of what you want to do.
    As a general rule, there is no way to call a client side Javascript function from a backing bean, which is server side. However, there are ways to inject information from a backing bean into your Javascript call. For instance, I have an application that uses Google Maps API. It has an onload call to a Javascript function that builds the map and designates it's center point. The center point comes from a backing bean as latitude and longitude properties. So here is my body tag:
    <afh:body onload="initialize(#{backing_searchResults.latitude},#{backing_searchResults.longitude},#{searchCriteria.distance})"
              onunload="GUnload()">onload calls the Javascript function called initialize, and passes the latitude, longitude, and distance from the bean. Is the function really being called from my backing bean? No - the parameters are hard coded into the onload event code when the page is rendered. Does it do the job? Sure it does.

  • Web services and ADF 11g- get Result from backing bean

    I'm executing an action from backing bean (call Web service that returns complex data types)
    BindingContainer bindings = getBindings();
    OperationBinding operationBinding = bindings.getOperationBinding("unesiPonudu");
    Object result = operationBinding.execute();
    result is instance of oracle.adf.model.adapter.dataformat.XMLHandler$DataCollection but DataCollection is not accessible.
    How to get results from method?
    Tnx,
    Andreja

    Hi,
    there should be a result iterator in the Executables section which cotnains the result. If not, create it from the WS result entry in the DC palette. Once this iterator gets updated, you get the data from this iterator as it would be the case of a table accesses the WS
    Frank

  • Is it recommended to instantiate Model object from Backing Bean

    Wondering what are the best practices in developing JSF,Spring, Hibernate application.
    Appfuse/Equinox example instantiate Model Object i.e. POJO in the Backing bean. Here is the snippet
    UserForm.java (Backing Bean)
    public class UserForm {
    public User user = new User();
    public UserManager mgr;
    // Getter & Setter methods for user & mgr
    //Persistence
    public String save() {
    mgr.saveUser(getUser());
    addMessage("user.saved", getUser().getFullName());
    return "success";
    I undertand the purpose of having UserManager defined in backing bean but wondering why do we need to have Model (i.e. User) defined in backing bean . Is this a best practice?
    Is it recommended to populate model object with data in the backing bean and then call for business methods like mgr.saveUser(getUser());
    Regards
    Bansi

    Here is some more info
    UserForm is a JSF managed bean,
    User is a hibernate mapped POJO, and
    UserManager is manager class in Spring
    I am wondering about perfomance issues i.e. making DB calls from backing bean getters or setters. DB calls can mean a performance hit, and JSF will call the getters and setters multiple times per page request (which means you'll be doing multiple DB calls).

Maybe you are looking for

  • Get distinct values from plsql array

    Hi, I have declared a variable as below in plsql proc. type t_itemid is table of varchar2(10); inserted set of items in to this using a program now i want distinct values from that array how can i get it.

  • Data quality check or automation

    Apart from passing the report to the user for testing are there ways the process can be automated for a data quality check and how? Thanks.

  • Mid 2007 imac not booting past apple logo, osx lion

    Hello, hope someone can help, need to finish an urgent website and after resarting my imac it just hangs at the apple logo. Worked fine this afternoon and when i went to reboot this evening just would'nt have it. Tried all the usual stuff, resetting

  • Broadcasting error email sending

    Hallo to everyone, i try to send a query by mail using broadcaster. My server was configurated for mail services. System log says me "error n. 829" What does it means? can anyone help me??

  • Run Time Error of PDK dotnet service after upgrading to SP17

    Hi All, I upgraded the portal from SP15 to SP17. Now, all my PDK.NET applications don't run. I get the following error: <i> iView cannot display. Could not connect to the .NET runtime server. Contact your administrator if the problem persists. Possib