How to call jpf controller method from javascript
Can any one help me how to call pageflow controller method from JavaScript.\
Thanks.
Accessing a particular pageflow method from Javascript is directly not possible unless we do some real funky coding in specifying document.myForm.action = xyz...Heres what I tried and it did not work as expected: I found another workaround that I will share with you.
1. In my jsp file when I click a button a call a JavaScript that calls the method that I want in pageflow like this: My method got invoked BUT when that method forwards the jsp, it lost the portal context. I saw my returned jsp only on the browser instead of seeing it inside the portlet on the page of a portal. I just see contents of jsp on full browser screen. I checked the url. This does make the sense. I do not see the url where I will have like test1.portal?_pageLabe=xxx&portlet details etc etc. So this bottom approach will notwork.
document.getElementById("batchForm").action = "/portlets/com/hid/iod/Batches/holdBatch"; // here if you give like test1.portal/pagelable value like complete url...it may work...but not suggested/recommended....
document.getElementById("batchForm").submit;
2. I achieved my requirement using a hidden variable inside my netui:form tag in the jsp. Say for example, I have 3 buttons and all of them should call their own action methods like create, update, delete on pageflow side. But I want these to be called through javascript say for example to do some validation. (I have diff usecase though). So I created a hidden field like ACTION_NAME. I have 3 javascript functions create(), update() etc. These javascripts are called onclick() for these buttons. In thse functions first I set unique value to this hiddent field appropriately. Then submit the form. Note that all 3 buttons now go to same common action in the JPF. The code is like this.
document.getElementById("ACTION_NAME").value = "UPDATE";
document.getElementById("batchForm").submit.
Inside the pageflow common method, I retriev this hidden field value and based on its value, I call one of the above 3 methods in pageflow. This works for me. There may be better solution.
3. Another usecase that I want to share and may be help others also. Most of the time very common usecase is, when we select a item in a drop bos or netui:select, we want to invoke the pageflow action. Say we have 2 dropdown boxes with States and Cities. Anytime States select box is changed, it should go back to server and get new list of Cities for that state. (We can get both states and cities and do all string tokenizer on jsp itself. But inreality as per business needs, we do have to go to server to get dynamic values. Here is the code snippet that I use and it works for all my select boxes onChange event.
This entire lines of code should do what we want.
<netui:anchor action="selectArticleChanged" formSubmit="true" tagId="selectPropertyAction"/>
<netui:select onChange="document.getElementById(lookupIdByTagId('selectPropertyAction',this )).onclick();" dataSource="pageFlow.selectedArticleId" >
<c:forEach items="${requestScope.ALL_ARTICLE}" var="eachArticle">
<%-- workshop:varType="com.hid.iod.forms.IoDProfileArticleRelForm" --%>
<netui:selectOption value="${eachArticle.articleIdAsString}">${eachArticle.articleItemName}</netui:selectOption>
</c:forEach>
</netui:select>
See if you can build along those above lines of code. Any other simpler approches are highly welcome.
Thanks
Ravi Jegga
Similar Messages
-
How to call a bean method from javascript event
Hi,
I could not find material on how to call a bean method from javascript, any help would be appreciated.
RalphHi,
Basically, I would like to call a method that I have written in the page java bean, or in the session bean, or application bean, or an external bean, from the javascript events (mouseover, on click, etc...) of a ui jsf component. I.e., I would like to take an action when a user clicks in a column in a datatable.
Cheers,
Ralph -
How to access the controller method from javascript onclick event?
Hi All,
I am totally new to development. And I got struck in calling a controller method from javascript function.
I have no idea about ajax and all those things. Please can anyone help me to solve this issue!
Thanks in advance.Hi,
As I know, you can use jQuery to do this, here is an example.
Example of your Controller Method.
[HttpPost] // can be HttpGet
public ActionResult Test(string id)
bool isValid = yourcheckmethod(); //.. check
var obj = new {
valid = isValid
return Json(obj);
and this would be your javascript function.
function checkValidId(checkId)
$.ajax({
url: 'controllerName/Test',
type: 'POST',
contentType: 'application/json;',
data: JSON.stringify({ id: checkId }),
success: function (valid)
if(valid) { //show that id is valid }
else { //show that id is not valid }
If you have further issues, I would suggest you move to MVC forum, it is appropriate and more experts will assist you.
Best Regards,
Jambor
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
How to call backing bean method from java script
Hi,
I would like to know how to call backing bean method from java script.
I am aware of serverListener and [AjaxAutoSuggest article|http://www.oracle.com/technology/products/jdev/tips/mills/AjaxAutoSuggest/AjaxAutoSuggest.html]
but i am running in to some issues with [AjaxAutoSuggest article|http://www.oracle.com/technology/products/jdev/tips/mills/AjaxAutoSuggest/AjaxAutoSuggest.html]
regarding which i asked for help in other thread with subject ....Question on AjaxAutoSuggest article (Ajax Transactions Using ADF and J...)
The reason why i posted is ( though i realise both are duplicates) .. that threads looks as a specific question to that article hence i would like to ask the quantified problem is asked in this thread.
So could any please letme know how to call backing bean method from java script
Thanks
Murali
Edited by: mchepuri on Oct 24, 2009 6:17 PM
Edited by: mchepuri on Oct 24, 2009 6:20 PMHello,
May know how to submit a button autoamtically on onload of page with clicking a welcome alert box. the submit button has managed button too to show a message on console using SOP.
the problem is.
1. before loading the page a javascript comes on which i clicked ok
2. the page gets loaded and the button is there which gets automatically clicked and the managed bean associated with prints a message on console using SOP.
I m trying to do this through server listener and click listener. the code is(adf jspx page)
<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
<jsp:directive.page contentType="text/html;charset=UTF-8"/>
<f:view>
<af:document id="d1" binding="#{backingBeanScope.backing_check4.d1}">
<af:form id="f1" binding="#{backingBeanScope.backing_check4.f1}">
<af:commandButton text="commandButton 1"
binding="#{backingBeanScope.backing_check4.cb1}"
id="cb1" action="#{beanCheck4.submit1}"/>
<af:clientListener type="click" method="delRow"/>
<af:serverListener type= "jsServerListener"
method="#{backingBeanScope.backing_check4.submit1}"/>
<f:facet name="metaContainer">
<af:resource type ="javascript">
x=confirm("hi");
// if(x){
delRow = function(event){
AdfCustomEvent.queue(event.getSource(), "jsServerListener", {}, false);
return true;
</af:resource>
</f:facet>
</af:form>
</af:document>
</f:view>
<!--oracle-jdev-comment:auto-binding-backing-bean-name:backing_check4-->
</jsp:root>
the backing bean code is -----
public class classCheck4 {
public classCheck4() {
public String submit1() {
System.out.println("hello");
return null;
} -
Calling view controller method from component controller method
Hi,
Is there any way to call view controller method from component controller method?
Thanks,Hi Khandal.
You should not make you component controller dependent from a view controller.
But what you can do is to define an event in the component controller. The view
controller can register for this event.
In the stage where you currently want to call the view controller method just fire
the event. In the event handler method in the view controller you can call the
method then.
Why do you need to call a view controller method? Can you give more details
about the scenario?
Cheers,
Sascha -
How to call a set method from within a constructor
Hello,
I want to be able to call a set method from within a Scanner, to be used as the argument to pass to the Scanner (from a source file). Here's what i tried:
private void openFiles()
input = new Scanner( setSource );
and here is the set method:
public String setSource( String in )
source = in;
return source;
}obviously there will be more code in this method but i'm trying to tackle one problem at a time. Thanks in advance..The "String in" declaration says: "Nobody may ever invoke setSource() without specifying a certain String. The content of the String is known at run-time only."
In no place in your code you say the compiler: "I want the 'in' variable (actually, parameter) of method setSource() to contain the first arg which is passed to the application".
This is exactly the same mechanism allowing you to write "new Scanner" with something inside the two parentheses. -
How to call an ejb method from jsp?
Hi, everyone!
Inside my JSP, I4m using scripts in order to show and receive information, that is, a form.But I don4t Know if I can use the same variables from the script in order to call the 'set' methods from my EJB.
Could anyone show me an example?
Thanks in advance,
SilviaInitialContext ctx = new InitialContext();
GeneralEditor editor = (GeneralEditor) ctx
.lookup("GeneralEditorBean/remote");
GeneralService service = (GeneralService) ctx
.lookup("GeneralServiceBean/remote");
LanMu lm = new LanMu();
lm.setName("shdfkhsad");
editor.add(lm); -
How to call a controller in a javascript
Hi,
I 've lot of doubts listing all of them down.
My requirement is
I need to create a master screen for Po and populate some data in dropdownlistbox with database table values and need to validate form and then save in database using MVC.
I was able to create a BSP and populate it using a model and do validations using javascript .
Now i need to save it in the databas.
I will be calling the same controller as i used initially
to call the BSP
1.How do i call a controller from my BSP in a javascript?
I tried by <bsp call url> but it doesnt seem to work.
2.When does the do_handle_event get triggered
Is it when i write some events and submit the form.
3.What is this Model Data Binding concept?Hi Welcome to SDN.
1. check out this link for call options
http://help.sap.com/saphelp_erp2005/helpdata/en/8f/3d473ccf20514ee10000000a114084/frameset.htm
2. check out this link on process flow
http://help.sap.com/saphelp_erp2005/helpdata/en/22/d59045f4d1174099260b71d5317908/frameset.htm
3. check out the following weblog on Model Data Binding
/people/sergio.ferrari2/blog/2006/08/28/bsp-in-depth-model-data-binding
Regards
Raja -
How to call a EJB method from Session bean method
Hi all,
I'm new to J2EE programming. I have a simple doubt .
I have already created a lookup method for EJB bean in Session bean .
My question is how to call a method of an ENTITY bean (say insertRow) from SESSION bean method(Say invoke_insertRow) .
Please provide me an example code .
Thanks in advance.InitialContext ctx = new InitialContext();
GeneralEditor editor = (GeneralEditor) ctx
.lookup("GeneralEditorBean/remote");
GeneralService service = (GeneralService) ctx
.lookup("GeneralServiceBean/remote");
LanMu lm = new LanMu();
lm.setName("shdfkhsad");
editor.add(lm); -
How to call a static method from an event handler
Hi,
I'm trying to call a static method of class I designed. But I don't know how to do it. This method will be called from an event handler of a web dynpro for Abap application.
Can somebody help me?
Thx in advance.
Hamza.To clearly specify the problem.
I have a big part code that I use many times in my applications. So I decided to put it in a static method to reuse the code. but my method calls functions module of HR module. but just after the declaration ( at the first line of the call function) it thows an exception. So I can't call my method. -
How to call view-controller method out of componentcontroller
Hello all,
my component implements a component-interface with method BACK.
Thus my componentcontroller has the interface Method BACK.
When triggering BACK from an foreign component, the implementation within the componentcontroller is called. So far so good.
Now I want to POPUP_AND_CONFIRM when BACK is hit. But this POPUP_TO_CONFIRM requires me to create an action. But I can't create an action within the componentcontroller.
I could realize the POPUP_AND_CONFIRM within the components view. But how can I call a view-method out of the componentcontroller?
Or does anybody have a better solution? (Maybe I could implement BACK within the view, but how to connect the componentcontroller-back-method with the views back-method?)
Thank you very much in advance...
Regards
I. DurmazYou should never attempt to call view methods from outside the view. It is possible to register popop event handlers to methods of the component or custom controllers. From the online help:
For a few special cases it is useful to register event handlers for component controllers or custom controllers on the button events of a dialog box. For these cases, a special POPUP_TO_CONFIRM attribute of type IF_WD_POPUP_TO_CONFIRM_N has been implemented in the IF_WD_WINDOW interface. This interface provides precisely the methods with which event handlers for component and custom controllers can be registered on events of the dialog box.
http://help.sap.com/saphelp_nw70ehp2/helpdata/en/47/b9487e01602fe2e10000000a42189d/frameset.htm -
Calling main controller method from component view
Hi,
Because i want to re-use certain views, i've created components of em so i can re-use them in several places within the same view. The problem is that i have 1 main component which has several methods calling webservices. I want the other components to be able to call the methods of the maincomponent. I tried adding the main component to the Used Web Dynpro Components of another component. Then i added the main component in the properties of the view but then it says: Cycle in component usage definitions.
I can understand this because the main view creates instances of all other components, so the sub components cannot create the maincomponent again...but how do i then give a reference of the maincomponents controller to the sub components?
Much thanks,
Hugo HendriksHi Siarhei,
The problem of creating a Java class is that there i dont have access to certain classes for example when there is something with a webservice, i want to send a message back like
IWDMessageManager msgMgr = wdComponentAPI.getMessageManager();
msgMgr.reportSuccess(message);
In a seperate java class, i dont have access to the wdComponentAPI! The only thing i want is kinda like a ServiceLocator to call different webservices. I do check roles of the user logged in the portal and stuff like that....How do you normally implement something like this? I have several views which have to make use of the locator....
I hope i dont need to create a seperate DC when i want to re-use a screen and want to call a service method of another class or so.........Sounds like much overkill for a screen with 2 inputfields and a button!
Anoop, i tried adding the mainController to the searchComponent by adding it to Used WebDynpro Components and then I added the mainController in the properties of the searchView so i can make use of it. In the searchcode i now can use the maincontroller but i still get the compiling message: Cycle in component usage definition!
best regards,
Hugo -
Call to Applet Method from JavaScript Failed.
I Am calling a method from a javascript function from within a web page.
The page is loaded into a frame. The parent window of the frame has stored a reference to the applet which defines the methods. Note I am treating the reterence to the applet as a global variable. So that I can reference it methods as I navigate from one page to another.
I have JavaScript objects defined, and I am passing them as parameters to the applet's methods. In java, the JavaScript objects are refererenced as JSObject. When I call a java method passing a JavaScript
Object I get the following exception. Note Iam using j2sdk1.4.2_01 on a Windows 2000 Professional System. This problem start occurring after the recent Microsoft Worm/Virus a fix was loaded on my system which resulted in the following bug. Could someone please help me.
java.lang.NullPointerException
at sun.plugin.javascript.ocx.JSObject.setIExplorerAppletContext(Unknown Source)
at sun.plugin.com.DispatchImpl.convertParams(Unknown Source)
at sun.plugin.com.DispatchImpl.invokeImpl(Unknown Source)
at sun.plugin.com.DispatchImpl$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.plugin.com.DispatchImpl.invoke(Unknown Source)
java.lang.Exception: java.lang.NullPointerException
at sun.plugin.com.DispatchImpl.invokeImpl(Unknown Source)
at sun.plugin.com.DispatchImpl$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.plugin.com.DispatchImpl.invoke(Unknown Source)A little code snippet would help. I use JSObjects from Java 1.4 no problem and do have all the latest updates. I also have JavaScript calling Java code as well - also with no problem.
-
How to call Backing Bean method from href tag in JSF. -- URGENT
Hi guys,
i am new to JSF. i want one option. how to call a backing bean method from href.
I searched a lot. i found one component <commandLink>, but i cann't use <commandLink> i have to use only href which is client instructions.
If anyone knows pls help me. Its Urgent. If u can, give me the code also.
Suggestions will be appreciated.
Thanks
RajeshYou can make use of the constructor of the backing bean or the @PostConstruct annotation if you want to use managed properties.
You may get some ideas out of this: [http://balusc.blogspot.com/2006/06/communication-in-jsf.html]. -
Through Enhancement, how to call a Webdynpro method from another webdynpro?
I have a standard page with 2 iViews with a standard abap webdynpro in each.
The first webdynpro needs to refresh the second webdynpro.
Through enhancement, I tried to follow the solution below:
first of all in the child component's component controller method(which you want to expose to another component) must be checked in the interface column.
Double click on the webdynpro project(parent component)->In the used components tab, in the column of component type the child project name(whose method you want to call) and in component usage column give any name->save the project.
goto the controller(VIEW or COMPONENT) from where you want to call the method->click create controller usage->select the interface controller of the child component->save the project.
click the code wizard->select method call in used controller->select the child component interface controller ->select the method you want to call.
Link of thread: Calling a method of other webdynpro component
But this solution doesn't worked because in this standard webdynpro is not possible to check the method as Interface.
Is there other way to do this?
Thanks.Hello,
you can refer the following documentation for portal eventing
http://help.sap.com/saphelp_nw70/helpdata/en/f6/7d6f4151dc5758e10000000a1550b0/frameset.htm
Br, Saravanan
Maybe you are looking for
-
ITunes 10.6.1 (7) acting weird?
Is anybody else having issues with 10.6.1 (7) ? It crashed when I tried refreshing my podcasts and when it reloaded a second Podcast icon appeared (empty). It then refused to synch all my podcasts with my iPhone and deleted them from the phone. I've
-
Screen Resolutions in OSX 10.8
Maybe someone can help, but if not - Apple, please sort this out, I've read complaints all over the net going back years... Screen Resolutions. This isn't difficult Apple. The video card in my 2008 Mac Pro (a geforce somethignorother) can display all
-
refer to above question...This is very frustrating...can't read my emails unless I switch to Internet Explorer...been dealing this for a week...pls advise?
-
Business Event Not showing up in EDN-DB-LOG
Hi There, I am programmatically raising an event from within a method. I have confirmed that this event is being raised and I can in fact see the events in database by executing the following query. select * from edn_event_queue_table However, The ev
-
My apps won't update, stuck on waiting.
My apps won't update, they have that grey bar on them. Every time I try to update them it says , unable to load. Please help?!?