I'm using JDeveloper 11.1.1.7.0 and I have this problem.
I have two different views, which are opened in the same web browser, in different tabs (maybe this is an important issue):
In view1, I have a Search button so, if data is found, show it, and if not, create it. Both ways, Search action ends accessing the related VO and making setCurrentRow programmatically
In view2 , I have another Search button, list data from the same VO in a table and, in the last column, there is a link with setCurrentRowWithKey operation with {row.rowKeyStr}. In view2, and next views in the related flow, there are only read operations.
So, my problem is this:
Access view1 in tab1, make a search and view data (setCurrentRow is executed).
Access view2 in tab2, make a search and view data in the table.
Here, if I click on setCurrentRowWithKey link, it fails and gives me back this failure:
oracle.jbo.RowNotFoundException: JBO-25020: No se ha encontrado la fila de vista con la clave oracle.jbo.Key[1042 ] en ...
1042 is the key selected in view1.
Why has happened that exception? Is it possible to work in this scenario?
Any help would be very appreciated. Regards
EDIT: The .jspx code
<?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 beforePhase="#{viewScope.myBean.pageAccess}">
<af:document id="d1" binding="#{viewScope.myBean.d1}">
<af:messages binding="#{viewScope.myBean.m1}" id="m1"/>
<af:form id="f1" binding="#{viewScope.myBean.f1}">
<af:pageTemplate viewId="/templates/templateReportes.jspx" id="pt1">
<f:facet name="usuario"/>
<f:facet name="contenido">
<af:group binding="#{viewScope.myBean.g1}" id="g1">
<af:panelGroupLayout id="contenidoCentral" layout="vertical" halign="center">
...
Error is while loading page, not invoking any method:
javax.el.PropertyNotFoundException: Target Unreachable, 'myBean' returned null
Related
I am new to JDeveloper and ADF. I am trying to make a popup appear on my webpage when I am using JDeveloper to make an ADF application. Here is my code:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<f:view xmlns:f="http://java.sun.com/jsf/core" xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
<af:document title="untitled1.jsf" id="d1">
<af:popup childCreation="deferred" autoCancel="disabled" id="somePopup">
<af:outputText value="Hello there" id="ot1"/>
</af:popup>
<af:commandButton id="button" text="Click me">
<af:showPopupBehavior popupId="somePopup" triggerType="action" />
</af:commandButton>
</af:document>
</f:view>
I believe I have done everything correctly in order for this popup to show, but when I click the button, nothing appears. I was thinking I might need a panel in order to show the text, but I don't think that is necessary. Do you guys have an idea of what's going on or how I should make a popup? My JDeveloper Version is: 11.1.2.2.0. I know this is a simple task, but I am stuck on getting it to show and would appreciate some help. Thanks guys.
It is a browser issue. The code is correct, I just can't find a way to get my browser to actually show it.
Add partialSubmit="true" attribute to your commandButton.
I think you are missing the af:form tag in your page.
This works for me in 12.1.3:
<f:view xmlns:f="http://java.sun.com/jsf/core" xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
<af:document title="untitled3.jsf" id="d1">
<af:form id="f1">
<af:popup childCreation="deferred" autoCancel="disabled" id="somePopup">
<af:outputText value="Hello there" id="ot1"/>
</af:popup>
<af:commandButton id="button" text="Click me">
<af:showPopupBehavior popupId="somePopup" triggerType="action" />
</af:commandButton>
</af:form>
</af:document>
</f:view>
First create the binding for the popup.In Command Button add Action Listener.Then in th action event method Write the below code..
RichPopup.popuphints hints = new RichPopup.popuphints();//hints is the object name
popupbind.show(hints); //popupbind is the property of popup
I've been facing some problems using JSF with AJAX to render a table without reloading the whole page every time I submit a form.
When I first run the server, my database is empty, so the page is supposed to show only a form to add books. When user submits the form, a fieldset whith all books is supposed to be rendered. I don't want this fieldset to be shown when database is empty.
This is a simple version of my code (it is just a small form and a table to be refreshed using AJAX):
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:head />
<h:body>
<h:graphicImage library="img" name="caelum-logo.png"/>
<h:form>
<p>Book Title:</p>
<h:inputText id="title" value="#{livroBean.livro.titulo}" />
<h:commandButton value="Add book" action="#{livroBean.addFirstBook}">
<f:ajax execute="#form" render="title :addedBooksTable" />
</h:commandButton>
</h:form>
<div id="addedBooksTable">
<p:fieldset rendered="#{livroBean.numberOfBooks > 0}">
<h:dataTable value="#{livroBean.allBooks}" var="book">
<h:column>
<h:outputText value="#{book.titulo}" />
</h:column>
</h:dataTable>
</p:fieldset>
</div>
</h:body>
</html>
And i wanna focus on this part:
<h:commandButton value="Add book" action="#{livroBean.addFirstBook}">
<f:ajax execute="#form" render="title :addedBooksTable" />
</h:commandButton>
The fieldset and the table inside it are supposed to be hidden when there's no book added to the database, that's why i used <p:fieldset rendered="#{livroBean.numberOfBooks > 0}">. But I want it to be rendered after I click the commandButton, even if there's nothing at the inputText.
Here's what's happening when I test the code:
if I test the code just as it is with an empty database, the inputText is refreshed (it "erases" what were typed before the submisssion) when I click on the commandButton, but the fieldset is not. I know that the fieldset has a rendered="#{livroBean.numberOfBooks > 0}" and the inputText does not, but the method getNumberOfBooks is called everytime i click the commandButton, that's why I don't get it...
if I change the f:ajax tag so it ends up like this <f:ajax execute="#form" onevent="click" render="title :addedBooksTable" />, it solves the problem, but i can realize the screen flashing for a while when I click the commandButton. As far as I know, one of the uses of AJAX is that we don't want the screen flashing when a request is made.
Why is the fieldset rendered only when I use onevent="click"? Should I consider the flashing something normal? Is there a more elegant solution for that?
Thanks!
You can't ajax-update a plain HTML element. You can only ajax-update a JSF component. Simple reason is that the target must be resolveable by UIViewRoot#findComponent(), so that JSF can find it in the component tree and render the updated HTML into the Ajax response.
Replace
<div id="addedBooksTable">
by
<h:panelGroup layout="block" id="addedBooksTable">
Normally, this should have thrown an exception as described in How to find out client ID of component for ajax update/render? Cannot find component with expression "foo" referenced from "bar", but they removed this check in Mojarra 2.2.5 in order to support ajax-updating a specific iteration of <ui:repeat> and <h:dataTable> (this missing check will be fixed later on as that's indeed unhelpful to starters like you).
As to why adding onevent="click" appear to work, that's because it caused a JavaScript error which in turn caused the whole JavaScript/Ajax thing to break down, which in turn caused that the command button fall backs to default synchronous behavior with a full page reload (as if you aren't using <f:ajax> at all). You likely meant to use event="click" instead. The onevent attribute serves a different purpose. See also a.o. Proccess onclick function after ajax call <f:ajax>.
I want to share my experience using primefaces, f:viewParam and p:commandButton, and ask a few questions.Take a look at this page:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:head></h:head>
<h:body>
<f:metadata>
<f:viewParam required="true" name="id_file" value="#{bean.idFile}" />
</f:metadata>
<h:form id="tableform" prependId="false">
<p:commandButton actionListener="#{bean.myMethod())}" icon="ui-icon-search" title="View" />
</h:form>
<p:messages id="messages" showDetail="true" autoUpdate="true" closable="true" />
</h:body>
</html>
The backing bean have a "myMethod()" method that does nothing. When you enter the page it expects the "id_file" parameter and put it in the idFile property of the backing bean. Then you click the button and the myMethod is called. Then you click again and you get an obscure validation error and myMethod is never called:
j_idt1: Validation Error: Value is required.j_idt1: Validation Error: Value is required.
First of all, remember that without p:messages you can't see this message, you have to dig the XML that primefaces send on ajax calls. Secondly, after 4 hours of debugging I've tried to change the f:viewParam like this:
<f:viewParam name="id_file" value="#{bean.idFile}" />
without "required": magically everything start working, I can click 1,2,3,etc and myMethod is called every time. So, the problem is that the ajax submit validate the parameter specified with f:viewParam, it sounds silly to me, but ok, I can live with it.
My questions are:
why this validation error doesn't appear the first time button is clicked? If you look at the ajax POSTs they are identical
it is supposed to be ok to validate the view parameters (that, in my idea, belongs to the view) on a partial ajax call?
is there a way to tell to primefaces not to validate on particular ajax request (process="#this" does not resolve)?
Thank you, I hope that my experience will allow you to avoid spending hours doing debugging!
The viewParam is a UIComponent. That means it's semantically no different from a <h:commandButton/> or a <h:inputText/> and it's liable to go thru every prescribed JSF request processing lifecycle phase, up to and including validation and conversion. In fact, the tag itself causes any given view to go into the full processing of any given page, just by being there
The <p:commandButton/> is going to do a postback, meaning, it's going to be re-requesting the same view, using a POST. So to solve your current problem, you need to base your required condition on that fact:
<f:viewParam required="#{!facesContext.postback}" name="id_file" value="{bean.idFile}"/>
What you get from the new condition is that the parameter will be required only on the first request. Subsequent postbacks will not trigger the condition. Just be sure you don't have any logic (maybe in a #PostConstruct that's built around that expectation
I'm using Richfaces to develop some web pages, with a datatable I try to display some data information from remote server. But its quite slow to load all data in one time, so I use a cache to store data, Firstly my cache is empty and data table is empty.
The ideal goal is loading one row from server(let say 1mins for each row) and store into my cache, then append into data table's end, my question is how can I render the content of data table from managedbean once I retrieve some new data into cache?
I also use a timer to update the cache values from server during a fixed period (1hour), that means later, new data could be added into cache, and old data could be removed from cache, that all depend on server's latest data. same question when I get a fresh cache and need rerender data table content according to cache values.
Thanks,
The most easy way to do this is rerendering your table. There are two approaches to do this using RichFaces library:
Client Side
The a4j:poll component defines a way to periodically poll a server in order to trigger state changes, or update parts of your page. It uses a timer to trigger each N milliseconds.
You can use it to check your cache data on your server and then rerender your table.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<h:form>
<a4j:poll id="poll" interval="2000" enabled="#{pollBean.pollEnabled}" render="poll,grid" />
</h:form>
<h:form>
<h:panelGrid columns="2" width="80%" id="grid">
<h:panelGrid columns="1">
<h:outputText value="Polling Inactive" rendered="#{not pollBean.pollEnabled}"></h:outputText>
<h:outputText value="Polling Active" rendered="#{pollBean.pollEnabled}"></h:outputText>
<a4j:commandButton style="width:120px" id="control" value="#{pollBean.pollEnabled?'Stop':'Start'} Polling"
render="poll, grid">
<a4j:param name="polling" value="#{!pollBean.pollEnabled}" assignTo="#{pollBean.pollEnabled}" />
</a4j:commandButton>
</h:panelGrid>
<h:outputText id="serverDate" style="font-size:16px" value="Server Date: #{pollBean.date}" />
</h:panelGrid>
</h:form>
</ui:composition>
More information on RichFaces a4j:poll.
Server Side
The a4j:push works as a consumer/producer architecture, which uses no timer, instead it uses a message that will instruct the client to re-render part of the page.
Using this component you will be able to have an impact on the client side (rerender HTML) from the java methods in your ManagedBean. Maybe the problem here will be to communicate your current cache architecture with your JSF Managed Bean.
More information on RichFaces a4j:push.
Regards,
Why aren't the Primefaces components rendered properly on partial page update?
The problem is -
I have a view with ui:include -
<ui:include src="#{navBean.viewId}.xhtml}"/>
and p:commandButton -
<p:commandButton action="#{navBean.setViewId('page1')}" value="Load DataTable"/>
and page1.xhtml is where I have a p:dataTable
<ui:composition xmlns ...
<h:head/>
<h:form>
<p:dataTable ...
Now, when I click on the command button, partial update takes place and everything is loaded but the data table is not rendered properly.
Does anybody here know how to get around this problem?
I went through some of the topics in the Primefaces forum but they didn't do any good.
Thank you.
Solution was simple -
Just include a
<h:head/>
as follows -
<ui:composition xmlns ...
<h:head/>
<h:form>
<p:dataTable ...
And now the p:dataTable renders as it is supposed to even on partial page update.