How to call a action on page load in jsf
Hi all,
i am having a JSF page where i want to display the records from the datatable. I have a method in bean which call database and gets the list of records. If i call this method from a link (action on this link) present on this page i can display the records on this page.
But i want to display these records at the time of page load only. How we can do this? How to call a action at the time of page load?
Thanks in adv.
If i am calling the database class and get the list in constructor only i am able to display list in the datatable on page load. This works fine. But the requirment is that if there are no records in the list display a error page with message-No records found! . But how i can navigate from the constructor to error page?
Like-
class MyBeam{
MyBean{
private List requestVOList = null;
MyDao dao = new MyDao() //for fetching list from DB
List records = dao.getList() //get list from dao class
if(records==null)
//Navigate to error page. How to do this navigation here?
else
requestVOList = records;
//setter/getters for requestVOList
}
Similar Messages
-
How to call java method on page load?
How to call java method on page load?
ThanksHey Dan,
Well, if you want to execute a java method when page is load, you need to put the clientlistener in af:document. Let me to show you an example (I can't find my post :P),
JSPX page:
<f:view>
<af:document>
<f:verbatim>
<script>
function loadPage(event) {
alert('Hello World!');
</script>
</f:verbatim>
<af:clientListener method="loadPage" type="load"/>
</af:document>
</f:view>If you try this code you can see that when the page has been load, you recieve the alert "Hello World!".
Furthermore, this is the javascript AJAX function that let you to call a servlet:
function ajaxFunction () {
var httpRequest;
if (window.XMLHttpRequest) {
httpRequest = new XMLHttpRequest();
} else if (window.ActiveXObject) {
httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
httpRequest.overrideMimeType('text/xml');
httpRequest.onreadystatechange = function() { alertContents(httpRequest); };
httpRequest.open('GET', '/appname/servletname', false);
httpRequest.send('');
function alertContents(httpRequest) {
if (httpRequest.readyState == 4) {
if (!httpRequest.status == 200) {
alert('Request error. Http code: ' + httpRequest.status);
}Where 'appname' is your application name and 'servletname' is the name of the servlet that you want to call. Obviously, you can call any URL ;)
JVN -
How to call a action in javascript
hi..
am a learner..
can anyone guide me how to call a action in Illustrator CS2 using javascript
thanks in advance,
JasyYep!
Maybe they prefer Apple. Maybe most of their buyers comes from that side. Maybe they dont know how to script.
Java would have been to hard for most of us. Javascript is everywhere on the web ... pages.
After so many years, they did not put the effort and money . This scripting idea is still for ' amateur' and to compensate for I dont know what. -
How to execute a method after page Load?
My question is very similar to what was discussed in following thread:
How to execute a method after page Load?
My requirement is that I want to run a method in backing bean of a page, immediately after the page gets loaded. In that method I want to invoke one of the method action included in the pagedef of this page, conditionally.
I tried using the approach given in the above thread, i.e to use <f:view afterPhase="#{backing_security.setPermPriv}">, but the problem is that our page is not using 'f:view' , so I explicitly added one f:view with afterPhase property set , but it is not working, page it self is not getting loaded, it is throwing the error:
Root cause of ServletException.
java.lang.IllegalStateException: <f:view> was not present on this page; tag [email protected]e8encountered without an <f:view> being processed.
at org.apache.myfaces.trinidad.webapp.UIXComponentELTag.setProperties(UIXComponentELTag.java:108)
at javax.faces.webapp.UIComponentClassicTagBase.findComponent(UIComponentClassicTagBase.java:733)
at javax.faces.webapp.UIComponentClassicTagBase.doStartTag(UIComponentClassicTagBase.java:1354)
at org.apache.myfaces.trinidad.webapp.UIXComponentELTag.doStartTag(UIXComponentELTag.java:71)
at oracle.adfinternal.view.faces.taglib.UIXQueryTag.doStartTag(UIXQueryTag.java:41)
at oracle.adfinternal.view.faces.unified.taglib.UnifiedQueryTag.doStartTag(UnifiedQueryTag.java:51)
at oracle.jsp.runtime.tree.OracleJspBodyTagNode.executeHandler(OracleJspBodyTagNode.java:50)
at oracle.jsp.runtime.tree.OracleJspCustomTagNode.execute(OracleJspCustomTagNode.java:262)
at oracle.jsp.runtime.tree.OracleJspNode.execute(OracleJspNode.java:89)
at oracle.jsp.runtimev2.ShortCutServlet._jspService(ShortCutServlet.java:89)
at oracle.jsp.runtime.OracleJspBase.service(OracleJspBase.java:29)
at oracle.jsp.runtimev2.JspPageTable.compileAndServe(JspPageTable.java:665)
at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:387)
at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:822)
at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:746)
Please help to resolve this issue, or am I doing anything wrong?Hi,
I assume that your view is a page fragment and here - indeed - the f:view tag cannot be used. If you use ADF then one option would be to use a custom RegionController on the binding layer to listen for the render phase to invoke the method. Another option would be to use a hidden field (output text set to display="false" and have this component value referencing a managed bean property. The managed bean property's getter method can now be used to invoke the method you want to run upon view rendering
Frank -
Smartforms - how to call 2nd secondary window page
Hi
How to call 2nd secondary window page from Ist Main window. The scenario is i have one main page. I have already called 2nd page thru command line and now want to call another page (i mean third page) from same main window. How do I do?
Thanx and regards,
Rajesh VasudevaHi Rajesh,
Go for the below link>>>>>
[http://help.sap.com/search/highlightContent.jsp]
thnks. -
How to call bean funtion once page is loaded?
Hi guys,
I am doing a user activation page. I need to call a bean function once the page is loaded. For example,
http://www.abc.com/activate.jsp?code=12345678
<c:if test="$"empty param.code">
<!-- call activate function a bean -->
</c:if>
public class UserBean{
private String code;
public activateAction(){
So how to call the above function? Thanks
regards,
kmthienHi, how to pass in the parameter to the bean? I am
using JSF framework !If you are using JSF, I have no clue. Never used it. Maybe ask in the JSF forum.
If it works the same as normal JSP/JSTL, then that last bit of code should do it (though I misspelled the property name:
<c:if test="${empty param.code}">
<c:set target="${instanceOfUserBean}" property="actionActivated" value="true"/>
</c:if>But like I said, if activateAction is a special method needed for JSF or something, ask in the JSF forum -
How do I execute a Action in the page flow on the load of a page. Say someone comes to my site and just directly types in www.mysite.com/lookhere.jsp ...
How do I make lookhere.jsp execute an action on the get request???One of my fellow engineers suggests using Servlet filter. You could map
*.jsp to the filter, and from the filter call the action.
DoesNot Matter wrote:
How do I execute a Action in the page flow on the load of a page. Say someone comes to my site and just directly types in www.mysite.com/lookhere.jsp ...
How do I make lookhere.jsp execute an action on the get request??? -
Very simple question: Call JavaBean method on page load?
Someone clicks on a URL that contains parameters like: http://server/page.jsf?param=b
How do I trigger a JavaBean method to run during page load? I see many JSF examples where JavaBean methods get called during form clicks and that works great but here I want to run code on page load.
This must be really simple; sorry I'm new to this technology.
Must I use <% ... %> syntax or can I use actual JSF tags or configuration to accomplish this?
Thanks very much in advance!Putting a lot of logic in getter( ) function is not the best idea considering that getter( ) could be called all over the place. Using constructor for same purpose is also a bad idea especially with request scope beans. This could also happen many times at different stages. You are right, having a page load concept could be useful. Unfortunately JSF framework does not support. You could architect around it in case desperate. Or if using JSF implementation of certain vendors like IBM, you can take advantage of their implementation that was extended to support pageLoad and postBack events (similar to .NET).
Many postings on this forum dealt with topic. Feel free to review like this one:
http://forum.java.sun.com/thread.jspa?forumID=427&threadID=541382 -
How to call Servlet from jsp page and how to run this app using tomcat..?
Hi ,
I wanted to call servlet from jsp action i.e. on submit button of JSP call LoginServlet.Java file.
Please tell me how to do this into jsp page..?
Also i wanted to execute this application using tomcat.
Please tell me how to do this...? what setting are required for this...? what will be url ..??
Thanks.well....my problem is as follows:
whenever i type...... http://localhost:8080/appName/
i am getting 404 error.....it is not calling to login.jsp (default jsp)
but when i type......http://localhost:8080/appName/login.do........it executes servlet properly.
Basically this 'login.do' is form action (form action='/login.do').....and i wanted to execute this from login jsp only.(from submit button)
In short can anyone please tell me how to diaplay jsp page using tomcat 5.5
plz help me. -
How to call navigation action?
Hello
I'm using JDeveloper 11g 10.1.1.3
I need to call navigation action on double click on the row of table.
I know how to use clientListener and serverListener, but I can't call navigation action (it is described in adfc-config.xml) from serverListener's method.
How could I do that?
AnatoliiAfter some time spended with all this staff, now I have a problem.
I have a page builded on a pageTemplate.
Inside this page I have one region with the bounded task flow "users" with table of users.
I created a button "btEditUser" and set action "toEditUser".
When I click on this button, I go to the nested task flow "editUser" (the page of editing user).
Next, I want to do that action after dblClick of the mouse button on the row of the table.
So, I created a clientListener and serverListener.
After processing some code (looking for selected row) the serverListener method processes next code:
ActionEvent actionEvent = new ActionEvent(btEditUser);
actionEvent.queue();(The button "btEditUser" is binded to the "btEditUser" attribute of my backing bean.)
This code is really processes (I traced that in the debagger), but nothing happens - after all I'm still on the first page.
I compared the logs of both variants of this action and found, that in the case with serverListener after processing this code i have next message:
<PartialPageContextImpl><<init>> PPR is about to render without any targetsWhat could it be?
Anatolii -
Z-Button - How to call a Action Profile to Open a PDF-Doc. within an Event?
Hi Experts,
we have created a Z-Button that afterwards creates an event. In the coding for the event an Action Profile should be called and a PDF-Document should be opened. We have copied the coding from the standard button 'Print Preview' which is calling the standard event: EH_ONPRINT_PREVIEW.
We have also defined a Z Action Profile which is a copie of SERVICE_CONFIRMATION. Our problem is we don't know how why our Z-Action Prodile is not called? What is the class lr_actioncontext (TYPE REF TO cl_crm_bol_entity)?
DATA: lr_cn TYPE REF TO cl_bsp_wd_context_node,
lr_adminh TYPE REF TO cl_crm_bol_entity,
lr_actioncontext TYPE REF TO cl_crm_bol_entity,
lv_adminh_guid TYPE string,
lv_url TYPE string,
lc_head_context TYPE REF TO cl_doc_context_crm_order,
lt_item_context TYPE ppftctxpos,
iv_header_guid TYPE crmt_object_guid,
lif_decision_pop TYPE REF TO if_bsp_wd_popup,
lv_string TYPE string.
CHECK gv_print_preview_enabled = abap_true.
lr_cn = me->get_context_node( gc_cn_btadminh ).
CHECK lr_cn IS BOUND.
lr_adminh ?= lr_cn->collection_wrapper->get_current( ).
CHECK lr_adminh IS BOUND.
lv_adminh_guid = lr_adminh->get_property_as_string( iv_attr_name = 'GUID' ).
lr_actioncontext = lr_adminh->get_related_entity( iv_relation_name = 'BTHeaderAction' ). "#EC NOTEXT
CLEAR gt_print_actions.
CLEAR gr_action_popup.
iv_header_guid = lv_adminh_guid.
CALL METHOD cl_crm_uiu_actions_tools=>get_action_definition
RECEIVING
rv_action_def = lv_string.
CALL METHOD cl_crm_uiu_actions_tools=>show_print_actions_popup
EXPORTING
ir_action_context = lr_actioncontext
ir_parent_node = lr_adminh
ir_view_controller = me
ir_component_controller = comp_controller
iv_event_name = gc_ev_print_preview_closed
iv_for_preview = abap_true
iv_appl_guid = lv_adminh_guid
IMPORTING
et_actions = gt_print_actions
ev_url = lv_url
CHANGING
cr_decision_popup = gr_action_popup.
IF lv_url IS NOT INITIAL.
call_print_preview_popup( lv_url ).
ENDIF.
Best RegardsClosed. No answers.
-
How to access the URL on page load and open it in the new tab of browser
Hi All,
I am using Jdeveloper 11.1.1.5 and i have one page "Hello.jspx" and one data control consist of two attributes :-one is "id" and other is "url".
The datacontrol has been created from the WebService.
Now my requirement is : -
whenever i run the page "Hello.jspx" , then on page load the url attribute should get accessed and should be opened in a new window or tab of the browser.As the url contains the information about the document.
Hello.jspx page doesn't contain any bindings of the url attribute.
I had thought of using the PhaseListener class and use the onPageLoad method .But how do i get the url from the dataControl and open it in the other tab of the browser on page load.
Please suggest!!!!
Thanks.Hi,
I don't think this can be done this way. I would think that you need to execute JavaScript upon Hello.jspx load to open a new window and pass the URL to it
Frank -
How To Pupulate A Combobox on Page Load in JSP
Hi All,
How to populate a combobox on a JSP Page load.
Please help.
Regards,
DineshThanks,
My current coding in jsp is :
To get the ArrayList from my DAOImpl class.
<%
newAppDAOImpl dao = new newAppDAOImpl();
dao.populateCombo(request);
ArrayList filetypes = (ArrayList)request.getAttribute("FILETYPES");
if(filetypes==null)
filetypes=new ArrayList();
pageContext.setAttribute("vecFileType" ,filetypes) ;
%>
For populating the combo:
<html:select property="retailer" onclick="/search">
<html:option value="----Select----"/>
<html:options collection="vecFileType" property="value"
labelProperty="label"/>
</html:select>
The above code is working for me.
Regards,
Dinesh -
How to call parameter of 101 page on page 1
Greetings,
i wanted to call parameter on login page "P101_USERNAME" on page 1 .
Cust_user is a table from where i m authticating my username and password, Authtication is doing fine but i want the customer id of the specific customer in the cust_user table to display after login on page 1. for that i wrote query on page 1 "SELECT cust_id FROM cust_user WHERE UPPER (USERNAME) =UPPER(:P101_USERNAME), but it is displaying nothing , if i harcore the specific username instead of :p101_username it is working fine e.g "SELECT cust_id FROM cust_user WHERE UPPER (USERNAME) =UPPER('test'),
Please gudie me how to get value of text field (p101_username login page ) on page 1, that is first page after login.Hi,
i wanted to call parameter on login page "P101_USERNAME" on page 1 .Cust_user is a table from where i m authticating my username and password, Authtication is doing fine but i want the customer id of the specific customer in the cust_user table to display after login on page 1. for that i wrote query on page 1 "SELECT cust_id FROM cust_user WHERE UPPER (USERNAME) =UPPER(:P101_USERNAME), but it is displaying nothing , if i harcore the specific username instead of :p101_username it is working fine e.g "SELECT cust_id FROM cust_user WHERE UPPER (USERNAME) =UPPER('test'),
Please gudie me how to get value of text field (p101_username login page ) on page 1, that is first page after login.>
Use :APP_USER. If your authentication scheme is working right then the username should be in :APP_USER.
Cheers, -
Method called three times on page loading
I have a page with panelTabbed and several showDetailItems. On the first showDetailItem I have ADF Query component with the results table.
I want the second showDetailItem to be enabled or disabled depending on whether there is a selected row in the results table or not.
I have second showDetailItem's Disabled property set to an EL expression referring to a method in a backing bean.
This method is called three times during initial page loading. I suspected that it was caused by some partialTriggers, but without any partialTriggers
ADF behave the same way.
Moreover, first two times there is a selected row in an iterator. Only the third time there's no selected row (empty initial state of the results table).
And if this method returns false (not disabled) first two times and true (disabled) third time only, the second showDetailItem is enabled after page is loaded.
What is responsible for these redundant calls of the method?Studio Edition Version 11.1.2.0.0
Build JDEVADF_11.1.2.0.0_GENERIC_110531.1615.6017
Maybe you are looking for
-
How to dynamically build where clause in Linq
Hello everyone, Oracle DB:11gR2 Oracle Client: 11.2.0.3.0 (ODP.NET) Oracle Developer Tools for Visual Studio VS 2010 (C#) In a Windows Form, we need to query the data based on the values of dropdown listboxes, which user will select. Let's say, two c
-
Reading attachments via Javamail gives ? characters
Hi, I'm using Javamail to read messages in a mailbox and to save the attachments that are on those messages. Some attachments are HTML documents that seem to contain bullet characters (doing a View Source on the HTML still shows the bullet, not "<li>
-
How to pass .txt file as an attachment to the web service (SOAP Attachment)
Hi, I am creating web service using NetBeans 6.5 IDE and JAX-WS. I create a web application and then create web service using provided interface. I want to add .txt file as an attachment/parameter to the web service operation using "Add operation" in
-
I'm a CC member, how can I troubleshoot reinstalling my CC & apps on my second computer?
I am a CC member trying to install CC on my second computer, but the CC menu stays blank. I had tried migrating my Adobe CC & apps over to my new laptop, but was prompted to re-download when I tried to open the apps. I was able to re-download CC, and
-
Despite MANY attempts Version 9 has NOT been provided to MY computer ! WHY NOT ?
I've been prompted to Download the newest version 9 MANY times in the past few months ! Each time I've gone through the Download procedure - even Restarting my computer. I'm SHOCKED to see that my computer CONTINUES to REMAIN on the oldest 'dying' ve