How to access application module from ActionForm Execute?

I've got a very simple ADF/UIX/Struts application where I'm trying to create a simple Login function. I have a /loginAction data action pointing to a login.uix page forward. The login.uix page has a <struts:form> on it with a user and a password field. There is a LoginBean with the corresponding get/set values. I have an ADF model created with a boolean login(String username, String password) function exposed as a client method.
Eventually, when I have this basic part working, then I'll actually be using an ActionForward mapping to dispatch to different home pages, based on the particular login account (the name of the forward will be stored in the authentication table).
I've tried overriding Execute(), since that is where you can return the appropriate ActionForward mapping, but that does not have a DataActionContext passed in -- so I can't get to the application module.
I've also looked at processComponentEvents, but that doesn't have any ActionForward results nor a way to pass back ActionErrors (in case the login fails).
How do I call my login client method when a user has entered a username/password and pressed the Submit button?

Here is another solution as provided by Oracle Support in response to a TAR that I opened:
I had described my need to access a login() function defined in my Application Module, returning true/false if the login succeeds/fails. Here is the reply, posted with permission:
I have gotten the following information back from one of the development folks pertaining to the question you asked.
His suggestions are as follows:
1) Expose the method as a client method on the App module
2) On the pageflow create a new DataAction
3) Drag and drop the logon method from the AppModule operations node and drop it onto the new data Action
3) Edit the set-property values that are created in the Struts metadata for this new DataAction to use the correct expressions to get the logon info to pass to the middle tier.
e.g.
<action path="/authenticateUser" className="oracle.adf.controller.struts.actions.DataActionMapping" type="AuthenticateUserAction" name="DataForm"
unknown="false">
<set-property property="modelReference" value="authenticateUserUIModel"/>
<set-property property="methodName" value="authenticateUserUIModel.authenticateUser"/>
<set-property property="resultLocation" value="${requestScope.methodResult}"/>
<set-property property="numParams" value="2"/>
<set-property property="paramNames[0]" value="${param.logonUsername}"/>
<set-property property="paramNames[1]" value="${param.logonPassword}"/>
<forward name="fail" path="/logon.do"/>
<forward name="success" path="/menu.do"/>
</action>
So in this case the values of the logonUsername and logonPassword fields in the form that submitted to this DataAction are passed as the two parameters that my authenticateUser method on the AppModule requires.
I have also overriden the data action class to customise the findForward() method to route the user depending on if the method call worked or not.
And here's the code for the customized FindForward in the DataAction:
protected void findForward(DataActionContext actionContext) throws Exception
HttpServletRequest request = actionContext.getHttpServletRequest();
HttpSession session = request.getSession();
String target = "fail";
//Get the result of the Model Method call
JUCtrlActionBinding method = actionContext.getCustomMethod();
boolean successfulLogon = ((Boolean)method.getResult()).booleanValue();
if (!successfulLogon)
// If the logon fails we need to do the following
// 1. Increament the counter once this exceeds 3 any logon will fail
// 2. Create an error message to display on the logon screen
// note this is a non specific error to prevent hackers from
// knowing that they at least got the username right or from
// knowing that there is a Max attempts value if they are trying
// an automated attack
Integer attempts = (Integer)session.getAttribute("logonAttempts");
int intAttempts = 0;
if (attempts != null)
intAttempts = attempts.intValue();
session.setAttribute("logonAttempts", new Integer(++intAttempts));
//The error message comes out of the ApplicationResources.properties file.
actionContext.getActionErrors().add("general",new ActionError("logon.error.logonFailed"));
this.saveErrors(actionContext.getHttpServletRequest(),
actionContext.getActionErrors());
else
//If connection was OK do we need to save the username in a cookie?
String remember = (String)request.getParameter("logonRemember");
int cookieLife = 0; //Expire
if ( remember != null && remember.length()>0 )
cookieLife = 2592000;
String name = (String)request.getParameter("logonUsername");
Cookie userCookie = new Cookie("CARA_USER_COOKIE",name);
userCookie.setMaxAge(cookieLife);
actionContext.getHttpServletResponse().addCookie(userCookie);
target = "success";
actionContext.setActionForward(target);
I hope this helps anyone looking to implement something similar. It also illustrates the "preferred" way of executing a client method and working with the result.

Similar Messages

  • How to call application module from ServletContextListener

    Hi,
    I've got an application that requires authenticated users. However, before the application starts I'd like to do some DB initialization.
    So I created a ServletContextListener and in contextInitialized method I try to createRootApplicationModule.
    Due to authentication / authorization requirements, createRootApplicationModule fails with:
    ov 12, 2008 12:09:33 AM oracle.adf.share.security.authentication.JAASAuthenticationService doLogin
    INFO: LoginContext.login...
    javax.security.auth.login.LoginException: Invalid null input: name
         at javax.security.auth.login.LoginContext.init(LoginContext.java:229)
         at javax.security.auth.login.LoginContext.<init>(LoginContext.java:367)
         at javax.security.auth.login.LoginContext.<init>(LoginContext.java:444)
         at oracle.adf.share.security.authentication.JAASAuthenticationService.doLogin(JAASAuthenticationService.java:102)
         at oracle.adf.share.security.authentication.JAASAuthenticationService.login(JAASAuthenticationService.java:89)
         at oracle.adf.share.security.authentication.JAASAuthenticationService.login(JAASAuthenticationService.java:71)
         at oracle.jbo.common.UserAznUtil.authenticate(UserAznUtil.java:62)
         at oracle.jbo.common.UserAznUtil.authenticateUser(UserAznUtil.java:29)
         at oracle.jbo.server.ApplicationModuleImpl.prepareSession(ApplicationModuleImpl.java:6387)
         at oracle.jbo.server.ApplicationModuleImpl.prepareSession(ApplicationModuleImpl.java:6356)
         at oracle.jbo.server.ApplicationPoolMessageHandler.doPoolMessage(ApplicationPoolMessageHandler.java:171)
         at oracle.jbo.server.ApplicationModuleImpl.doPoolMessage(ApplicationModuleImpl.java:8377)
         at oracle.jbo.common.ampool.ApplicationPoolImpl.sendPoolMessage(ApplicationPoolImpl.java:4364)
         at oracle.jbo.common.ampool.ApplicationPoolImpl.prepareApplicationModule(ApplicationPoolImpl.java:2421)
         at oracle.jbo.common.ampool.ApplicationPoolImpl.doCheckout(ApplicationPoolImpl.java:2207)
         at oracle.jbo.common.ampool.ApplicationPoolImpl.useApplicationModule(ApplicationPoolImpl.java:3086)
         at oracle.jbo.common.ampool.SessionCookieImpl.useApplicationModule(SessionCookieImpl.java:453)
         at oracle.jbo.common.ampool.SessionCookieImpl.useApplicationModule(SessionCookieImpl.java:424)
         at oracle.jbo.common.ampool.SessionCookieImpl.useApplicationModule(SessionCookieImpl.java:419)
         at oracle.jbo.client.Configuration.getApplicationModule(Configuration.java:1395)
         at oracle.jbo.client.Configuration.createRootApplicationModule(Configuration.java:1363)
         at oracle.jbo.client.Configuration.createRootApplicationModule(Configuration.java:1335)
    Can I somehow explicitly login a valid user or exclude the specific application module from authorization?
    Regards
    J

    Hi,
    no, the function is not related to user session. It's actually data synchronization between two systems.
    We'd prefere to keep it in middle tier, through web services on one side and AM on the other. This way we are platform / RDBMS independent.
    I could use a fake system user, eg. "sync" with password "sysnc", but how do I "log on" such user in my EJB code? If I could somehow access AM login context and call login with username and password...?
    Edit:
    it also puzzles me that it's possible to have a page within the aplication that allows anonymous access. The only difference in security context seem to be _isHttp property. getUserPrincipaly returns JpsAnonymousUserImpl in both cases, IsAuthenticated() is false in both cases...
    Edited by: Jernej Kase on Nov 13, 2008 8:57 PM

  • Cannot Access Application Module from View Project (Swing)

    I recently started a new application workspace as a Swing project with Business Components. Jdev created 2 projects by default, a Model and a View. The model works fine, all the business components are funtctioning and the DB connection is good. When i try to create a reference to the application module in my View project i constantly get 'Class Not Found' exceptions no matter what i do. I am using the jbo.client.Configuration.getRootApplicationModule('amName', 'amConfig') method.
    What am i missing? How do i instantiate my application module from my View project?
    Thanks a lot.

    Just had to add the Model to the classpath...

  • How to access application state from stateless web service?

    I have a beginner J2EE question. After reading through J2EE tutorial, I still don't know how to create an application that would run on J2EE server, and which would have a web service interface to other world, and which would have several threads running, which would connect to other enterprise applications via TCP? Because if I understand it correctly, web service requires a stateless session bean, which means that it can't access any stateleful session bean (except always create one and remove it instantly). So there seems to be no way to store application state and have running threads.
    I'm asking this because .NET seems to have a very simple Application dictionary, which can save all application objects, including threads, and it is very easy to access this Application state from a stateless web service. Isn't there any similar functionality in J2EE? And if not, how it should be done in Java world then?
    I guess that the Connector architecture could be the solution, but it is not documented in the tutorial.

    There's nothing in the J2EE spec that says that you have to use Web Services. Web Services by definition are stateless.
    If your requirements are that you have to use a session bean along with a Web Service, then the architecture needs to be rethought, because it doesn't seem to me that Web Services are what you want.
    That said, you can use a hybrid. You can expose some of the functionality of your application as Web Services while the remaining is implemented in a classic J2EE type framework that is stateful.
    I would also think that you could store your application state via entity beans. You could save and load them when the web service is accessed. An entity bean doesn't require a database... just some form of persistence (could be an XML file for instance).
    You need to decide which components of J2EE make sense when and where.

  • How to get application module instance from java bundle?

    Hi!
    I would like to build an application that would get all translations from a database table.
    So I created application module for translations that contains a view object which is selecting translations for specific language from a database table. I exposed a method in application module as client interface which returns HashMap<String, String> for all translations for specific language. When I test my view and client interface method call they work fine.
    Then I created java bundle classes to get translations for specific language. Then I tried to override public Object[][] getContents() method.
    I tried to get my translations application module like this:
    SharedTranslationsAppModuleImpl am = new SharedTranslationsAppModuleImpl();
    Map<String, String> translationsMap = am.getTranslations(this.getLocaleCode); // Client interface method call
    In getTranslations(String LocaleCode) I try to get that view (which would select translations from database) but it returns NULL and I get NPE error message.
    So what is the right way to get application module from java bundle file? Now everytime application wants to get translations, application stops and displays NPE message.
    Regards, Marko
    I use JDeveloper 11.1.2.1.0

    Marko,
    you can't just instantiate an application module. An application module has to be set up, db connections and memory pools have to be initialized and ....
    Can you describe why and when you try to read the resource bundle from the db and where the resource bundle is used?
    This blog may be what you are looking for http://technology.amis.nl/2012/08/10/implement-resource-bundles-for-adf-applications-in-a-database-table/
    Timo

  • What is the best way of accessing application module without page binding?

    Hi All
    I am using Jdeveloper 11g R2 (11.1.2.3) & Weblogic 10.3.5.0
    What is the best way of accessing application module without page binding?
    In my application after user authenticated from LDAP
    I need to read some information from database and set my menues.
    Thanks
    Mohsen

    Hi,
    if you don't have a binding the I am not sure the binding context is created. Anyway, try
    BindingContext.getCurrent().findDataControl("name here as ID in DataBindings.cpx") and see if it returns a valid instance
    Frank

  • Howto stop the application module from using a DB

    Hello,
    Maybe and unusual question, but is there a way to stop the application module from connect to a DB? I know its purpose is to do so. But currently we are using ‘stub’ views and entities.
    In the executequery and dodml we wrote our own code to access data from webservices.
    We did this because we are also using JHeadStart which requires BC.
    It all works fine, but the application module needs a valid connection to a DB, although it will never query anything there.
    So is there a method which I can overwrite to make the application module think its connected to the DB but it actually isn’t?
    A second problem is most likely its state table.
    Anton

    Example #96 on my blog does this. It might have some useful clues.

  • Referring Application Module from different Project

    I have two projects. a.jpr and b.jpr
    I need to refer an Application Module from b.jpr in the first project a.jpr
    In the Application Module edit Wizard, in the "available" list it shows all the Application Modules from the current project only.
    What do I have to do to see the Application Modules of the other project.
    In the "Project Settings" option, under "Dependencies" I have referred to the other project "b.jpr"
    But it didn't help.
    Any help is greatly appreciated.

    I have a similar problem as follows.
    I have two projects: a web WAR and an EJB3 EAR. On deployment all the EJB class files are generated into the WAR file and the contents of the EAR file only has the XML configuration and dependant jar files.
    How can I build the deployment EAR with the EJB classes within the jar? Why are they ending up in with the WAR WEB-INF/classes directory?
    This a significant problem and any help / advice would be appreciated.

  • How to Access Maintenance View from a program

    Hi Experts,
    I have created a maintenance view for a table. i want to insert data's into the table through the maintenance view. I don't know how to access the view, how to insert data into the Maintenance view. Please suggest me how to access the view from the program.
    with regards,
    James...
    Valuable answers will be rewarded...

    Hi,
    What is the need to search for a program.
    Use transaction SM30 or SE16 to create or maintain entries in the table.
    e.g. if the Maintenance view is created on table A, then Goto transaction SM30 or SE16 and give the table name as A and proceed. This will automatically take u to the maintenance view on tha table A.
    Regards,
    Himanshu

  • The difference in calling an application module from a backing bean

    Hello everybody!
    I don't understand exactly, where is the difference in calling an application module from a backing bean in the following ways.
    Example 1
    FacesContext context = FacesContext.getCurrentInstance();
    ValueBinding vb = context.getApplication().createValueBinding("#{data}");
    BindingContext bc = (BindingContext)vb.getValue(context);
    DCDataControl dc = bc.findDataControl("AppModuleDataControl");
    AppModuleImpl appModule = (AppModuleImpl)dc.getDataProvider();Example 2
    String amDef = "model.services.AppModule";
    String config = "AppModuleLocal";
    AppModuleImpl appModule = (AppModuleImpl)Configuration.createRootApplicationModule(amDef, config);Example 3 (the same like Example 1???)
    String EL = "#{data.AppModuleDataControl.dataProvider}";
    FacesContext fc = FacesContext.getCurrentInstance();
    ValueBinding vb = fc.getApplication().createValueBinding(EL);
    AppModuleImpl appModule = (AppModuleImpl)vb.getValue(fc);Please can anybody explain, what the three examples do? Which example is preferred to call an application-module-method from a backing bean?
    Thanks and regards
    Majo
    Edit: I am using ADF BC 10g in JDev10 :)

    Hi :)
    >
    This could work, but can you describe the use case for which you need to get the ApplicationModule?
    Maybe we can find a better way to implement your functionality.
    >
    Sure, i know a lot of better ways to implement the same functionality too but its a huge project, its not my code and we have no time to reimplement this functions ;)
    Frank, i don't understand the first line of your code.
    DCBindingContainer bindings = ... resolve #{bindings}Where do i get the bindingContainer, if I don't have the "JSFUtils"- or "ADFUtils"-classes?
    Regards
    Majo
    Edit:
    Sorry, i have answer, before i think about it ;)
    FacesContext context = FacesContext.getCurrentInstance();
    Application app = context.getApplication();
    DCBindingContainer bindings = (DCBindingContainer)app.getVariableResolver().resolveVariable(context, "bindings");
    BindingContext bctx = bindings.getBindingContext();
    DCDataControl dc = bctx.findDataControl("AppModuleDataControl");
    AppModuleImpl am = (AppModuleImpl)dc.getDataProvider();or in my backing bean, when i add the property to the faces-config.xml
    DCBindingContainer bindings = this.getBindings();
    BindingContext bctx = bindings.getBindingContext();
    DCDataControl dc = bctx.findDataControl("AppModuleDataControl");
    AppModuleImpl am = (AppModuleImpl)dc.getDataProvider();Is this right?

  • How to send application acknowledgement from R/3 system

    Hi guys,
          How to send application acknowledgement from R/3 system. Ex. we have post one IDoc and check user validations. Suppose date is wrong that means indicate earlier or wrong date but date format is correct. In this situation we need send one acknowledment to sender.
    How to find the solution? pls tell anyone.
    Regards
    Vijay

    Hi Vijay,
    Plz do perform the following steps:
    1) In the Integration Server, call transaction SE38
    2) Run program IDX_ALEREQUEST to process IDocs with message type ALEAUD as XI request
    message.
    3) Now Enter Sender Port, Sender Client,Partner Number, Partner Type, and Partner Rol
    4) In Integration Directory, configure the routing of interface
    5) Call transaction SXMB_MONI to display the XI message.
    Also,
    Further in IDX5 as well you will find entry for IDoc ALEAUD.ALEAUD01
    Please go through the link
    1)Succesful IDOC acknowledgements from ECC
    2)https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/903a0abc-e56e-2910-51a8-9dc616df56eb
    3)https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/f6d2d790-0201-0010-9382-b50b499b3fbe
    After you triggered the IDoc by e.g. tcode: WPMA and IDoc reached FILE system, FILE receiver CC actually is only able to send acknowledgment types SystemErrorAck and AckNotSupported.
    This is because:
    - IDoc sender adapter requests the following acknowledgments:
    SystemAckRequested="false"
    SystemErrorAckRequested="true"
    ApplicationAckRequested="true"
    ApplicationErrorAckRequested="true"
    - File receiver adapter “that run on the Adapter Engine support system acknowledgments and system error acknowledgments if they are requested by the sender. These acknowledgments are triggered when a message is successfully processed by the adapter or if an error occurs while it is being processed.”
    If you haven’t suppressed acknowledgments for IDocs WP_PLU in IDX_NOALE in XI then you will get:
    SystemErrorAck – when message has not reached the FILE system
    AckNotSupported – for all others acknowledgement types
    QQ) Will this IDOC Ack applicable for this scenario???
    Rather not, since FILE adapter does not support any other acknowledgements then system and IDoc adapter does not request other acknowledgements then application + SystemErrorAckRequested.
    In sender system your IDoc will be always in status 39 (instead of 03), when acknowledgement is turned on.
    This is because:
    For SystemErrorAck the corresponding ALEAUD status is 56
    For AckNotSupported the corresponding ALEAUD status is 50
    Both inbound 56 and 50 statuses end up in 39 for your outbound IDoc in sender system.
    Q1) Will this ALEAUD Idoc contains any Message from File System????
    In both cases, it will result in status 39 - IDoc is in the target system. So it does not matter.
    Q2) Basically what Information will contain this IDOC Ack.
    Idoc number from sender system and status 56 or 50 depends on acknowledgement type.
    Q3) Do we receive any Info from the Target File System , if we implement this Ack concept??
    Nothing useful.
    Remember that “File Receiver has no way to determine if the written file has been correctly processed by the back-end application”. However, if your “FILE” application can read your WP_PLU message and after successful processing is able to generate any kind of message then you can acknowledge the communications but you will not be able to link original message with the acknowledgement request message.
    To do that you need to configure just normal scenario (that will be your new acknowledgement scenario) FILE -> XI -> R/3. Your FILE service will send ALEUAUD Idoc to R/3 system. Your FILE application must take care to generate proper ALEAUD XML message. In order to treat ALEAUD as a request message (not standard acknowledgement) you need to run IDX_ALEREQUEST in SE38 on XI.
    Q1) It means if the Idoc not reached to Target File system means we can able to get the System Error Ack to Sender SAP R/3 System. Am i Right????
    Supposed you have turned off acks on XI (tcode: se38, IDX_NOALE) for your sender port/client:
    You have sent the IDoc and the last status is "03 - Data passed to port OK"
    You don't know whether it was even delivered to XI ...
    Supposed you have turned on acks on XI (tcode: se38, IDX_NOALE) for your sender port/client.
    1)
    You send and IDoc and it has been delivered successfully to FILE system.
    Adapter Engine creates acknowledgement type: AckNotSupported
    In XI you can see Ack Status: AckRequestNotSupported (Acknowledgement not possible). Category: permanent.
    XI will send ALEAUD IDoc to R/3 system: status "50 - IDoc is added"
    The IDoc status in sender will be "39 - IDoc is in receiving system (ALE service)".
    2)
    You send and IDoc and it has not been delivered successfully to FILE system. e.g. FILE server is down.
    Adapter Engine creates acknowledgement type: SystemErrorAck
    In XI you can see Ack Status: Error (Acknowledgement contains system errors). Category: transient.
    XI will send ALEAUD IDoc to R/3 system: status "56 - IDoc with errors is added"
    The IDoc status in sender will be "39 - IDoc is in receiving system (ALE service)".
    So status 39 means only that IDoc reached XI, but you don't know whether it was delivered to FILE system or not.
    Q2) And one more thing is Even though we are dealing with the IDOCFile OR FileIDOC we can able to get the ACk of Type System Error Ack only. Am I Right?????
    No, "Sender adapters of the Adapter Engine do not request any acknowledgements."
    Q3) So the same case( Which we disscused for IDOCFile) is Applicable for FileIDOC also????
    No.
    Can we able to get the System Error Ack, if the File is not reached to SAP R/3( Target here)
    No.
    Q4) If Yes to Q3 means,Where this System Error Ack will be seen in File System side???
    Do we need to do any extra settings to receive these System Error Ack at File system side??
    Not relevant.
    Regards,
    Vinod.

  • Nokia 6230i : how to send applications java from ?

    How to send applications java from nokia 6230i to an other nokia 6230i ?
    Looking for applications: "converter II, world clock II, translator".
    thanks.

    as hole is right ,there is no way can be sent , but i would like to know how the Mosh is working and which way everybody uploading the apps to Mosh ? i have downloaded apps from Mosh and want to send it to another phone and also i like to send some apps games to Mosh , thanks for any advise .
    The only thing necessary for the triumph of evil , is for good men to do nothing .

  • How to access Oracle 8g from SQL Server 2005 SP3 EE 64 Bits ?

    Dear All,
    How to access Oralce 8g from SQL Server 2005 SP3 EE 64 Bits (liked server).
    Best regards,
    Miguel Gavinhos

    Hi!
    For the Oracle version is 8.1.6. what should I install, to access Oracle trought a linked server.
    Best regards
    Miguel Gavinhos

  • How to access the cloud from my pc?

    how to access the cloud from my pc?

    Go to Verizonwireless.com, log in to your account (or register your phone number if you haven't done so).  Once logged in, Go to My Verizon, My Device, Backup my contacts.  That should bring you to your Cloud "dashboard" - where you can view Contacts, Photos, Videos, Music,Documents, and anything else  you've sent to Verizon Cloud.
    If this doesn't work for you, then where does it break down?  Do you get any error messages?

  • How to access the Oracle from Unix when SID is not provided?

    How to access the Oracle from Unix when SID is not provided.
    User Name : xxx
    Password : yyy
    SID : SID
    I use to access it using below command from Unix prompt:
    sqlplus xxx/yyy@SIDNow since I dont have SID, how to access the Oracle DB from Unix Box?
    User Name : xxx
    Password : yyy
    Service Name : zzz
    Regards,
    Sunny.

    Hi Ajay
    Thanks for the suggesstion :)..It worked as well.
    The Actual problem was in the "tnsnames.ora" file where in I need to make entry for the new SERVICE name.
    Now I am able to connect it properly.
    Regards,
    Sunny.

Maybe you are looking for

  • Issue in PO Release Workflow WS20000075

    Hi All, We have activated Std. PO release Workflow WS20000075 for two step release levels. When New PO created with release strategy this workflow will trigger and send workflow items to Agents to release Purchase Order. Up to this it's working fine.

  • Ubuntu 15 openjdk version "1.8.0_45-internal"

    hi I updated my is to Ubuntu 15 and when I even writing hello World Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar that shows me this error I searched a lot into web but I couldn't solve it I saw some solution on Stack Overflo

  • Photosmart 3210 All-in-One printer will not read Micro SDHC memory card. Help!

    I have a Photosmart 3210 All-in-One printer that will not read my Micro SDHC memory card. Help! I get an memory card error message but no idea where to go from there.

  • How to display all validator messages at the same time?

    Hi Guys, I have a form with validators attached to a couple of my input boxes. I tried to write validators which are reusable in other parts of my app ie. social security number check etc. I also then customized the messages and it all works fine. Bu

  • Pacman + -Syu = system freeze

    I cannot post console output because system freeze so i cannot cut& paste. My pacman output is localized so my translation may not be 100% accurate After i pacman -Syu i get a list of packages hit y they get downloaded then pacman is checking depende