PrepareForDML method called twice
Have implemented a typical scenario (search - add - edit jspx pages).
Within one application module, one view object with dynamically created where criterion is used for searching, and another view object fetching at most one row is used for inserting/updating. The second view object is based on a join of an updatable entity (that has as primary key trigger-generated sequence number) and several referenced readable entities that bring descriptions of the codes of the updatable entity. Have implemented descriptions as output fields in the jspx, settign partialTriggers to the id of the code-field of the updatable entity having autoSubmit=true. Have concentrated business validation logic within the prepareForDML() of the updatable entity implementation.
Under normal conditions, it works fine.
Under heavy system load in production, or testing with ADF State Management enabled at work environment, I observe the prepareForDML() called twice instead of once.
Thus, the first time the insert is commited, the second time the validation rollback, and at last the whole transaction is rollbacked.
When I commented-out all the fields that bring descriptions and set all autoSubmit=false, prepareForDML() was called once.
However, my problem is that I have to bring the descriptions, that result from pop-up windows so that the end-user can see them after selecting sthg on his/er screen.
Why is prepareForDML() called twice, and how can I avoid this?
(2) Can't change the second trigger-assigned field from DBSequence to simply Number since the Entity Object Editor hides the tab Sequence to declare the sequence from which to get this field's value after insert.
Please see section "6.6.3.8 Trigger-Assigned Primary Key Values from a Database Sequence" of the ADF Developer's Guide for Forms/4GL Developers on the ADF Learning Center at http://www.oracle.com/technology/products/adf/learnadf.html for more information on this. The "Sequence" tab doesn't have any runtime behavior influence. The sequence number is not assigned by ADFBC, it is assigned by your trigger. ADFBC only worries about:
1) Providing a temporary unique negative key so that new detail rows can have a temporary foreign key value to point at until the transaction commits
2) Refreshing the entity object's primary key value from the database-trigger assigned sequence number (however, we really don't know how the trigger populated the value) Theoretically, it may or may not have used a database sequence to assign the number. It would work just the same at the ADFBC level)
3) Refreshing the temporary negative foreign key values in newly-created detail rows for new, composed details of the new composing master row with the definitive primary key value.
So, you should safely be able to change this to a Number, with its Refresh after Insert property set.
(3) Create() on entity implementation was always called once at page load, unexpectedly prepareForDML() always carried on two consequtive rows (either the new row to insert twice or the query's first row retrieved to update and afterwards the new row to insert) having State Management enabled.
If create() is being called only once, then next you should check the value of the "operation" flag that is passed to prepareForDML() to understand if the method is being called for DML_INSERT or DML_UPDATE. Perhaps somehow an existing row is being inadvertently updated so one of the calls to prepareForDML() might be an update? I don't understand how prepareForDML() could fire twice for two new entity objects if the entity object's create() method is only called once. If you have a testcase that illustrates this, please report it to Worldwide Support via Metalink so they can triage and file a bug for you on it.
(4) Swapping selectInputText components with SelectOneChoice, thus avoiding the partial page rendering, I managed prepareForDML() to function logically so that to have only one row to insert, but again since I have validation code in my entity implementation that throws JBO-exceptions, another problem occured. The first time the end-user receives an exception (e.g. invalid Tax Number), the second time he/she corrects it, the created row instance at prepareForDML() doesn't get updated with the new valid Tax Number, but continues to hold the old value at second run. To remind that if insert is successful the navigation moves on to the update page, otherwise it remains at the same (navigation outcome is null).
Are you absolutely sure in this case that a second new row is not getting created?
Similar Messages
-
Why valueChaged( ) method called twice
Dear All,
I have made a class MyList by extending JList and implements ListSelectionListener and override valueChanged method. When we clicked on the list item this method called twice. Can you please explain the region?
I write my code like that:
Public void valueChanged(ListSelectionEvent lse)
System.out.println(�Hello�);
Out put:
Hello
Hello
Thanks
Bipin KumaIt's expected - check the details and you'll see why.
If, say, the user had selected item 3 and then select item 8 then you might get two events:
1. first 3, last 3, isAdjusting true
2. first 8, last 8, isAdjusting false
It's a poor event protocol if you ask me but there you go. -
Why is the ActionForms validate-Method called twice?
Hello forum,
I'm new to struts and want to develop a form, where an internetuser can leave a comment to an article. Just like most sides, an image with an text is displayed, the text has to be written into an inputfield before the comment is commited in order to be saved.
When an user puts in no text or a wrong one, a errormessage is displayed, the old image is deleted and an new one is created and shown to the user. His input still stays in the fields.
I proof the correctness of the word in the validate-Method of the ActionForm and it works fine.
Now I've the following problem:
If the user puts in the correct text, the comment is saved and the side is displayed again including his comment.. But also all the input of the form should be erased. But for some reason, its not and the validate method is called again and since there is a new wordvarifyingimage and a new text to be inserted, it throws an error which is displayed again. Also, all the input of his last message is present!
So, I guess I miss a big point about the ActionForm handling. Why is the ActionForm called twice and why doesn't it erase the old input? I try to do this in the Action class after saving the comment, setting all the formparameters to "" or null.
Can anybody give me a hint?
Would be a big big help since I've not found anything googling about this issue.
If you need code, just tell me which part I put in here (ActionForm, Action, struts-config or jsp-file)
Thanxs in advance,
strutsnewbytopromy jsp:
<%@ taglib uri="/WEB-INF/tld/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="struts/html-el" prefix="html" %>
<%@ taglib uri="jstl/c" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/struts-logic.tld" prefix="logic" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<style type="text/css" title="currentStyle" media="screen">
@import "../library/css/blog.css";
</style>
<script language="javascript">
function sendMail(){
document.forms[0].formaction.value ='mail';
document.forms[0].submit();
function saveComment(){
document.forms[0].formaction.value ='comment';
document.forms[0].submit();
</script>
</head>
<body>
<html:form action="/blog">
<div id="container">
<div id="leftside">
<logic:messagesPresent>
<div id="errors">
<div style="color:#CC3333; ">
<p><span id="errorHeaders"><bean:message key="errors.validation.header"/></span>
<html:messages id="error">
<c:out value="${error}"/>
</html:messages>
</p></div>
</div>
</logic:messagesPresent>
.... show blogentry ...
<logic:present name="comments">
<div id="divblogcomment">
<logic:iterate name="comments" id="com">
<div class="breaker10" style="clear:left; "></div>
<div class="rowblogcommentdate" style="width:150px;"<a href="<bean:write name="com" property="website" />"><bean:write name="com" property="username" /></a> am <bean:write name="com" property="postdate" /></div>
<div class="rowblogcomment"><bean:write name="com" property="comment" /></div>
</logic:iterate>
<div class="breaker10" style="clear:left; "></div>
</div>
</div>
</logic:present>
<logic:notPresent name="savedcomment">
<div id="writeblogcomment">
<div class="topbig"><div class="headsmall">enter Comment</div></div>
<div id="bginhaltwriteblogcomment">
<div class="breaker10" style="clear:left; "></div>
<div align="center">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td>Name:</td>
<td> </td>
<td><html:text size="50" name="blogForm2" styleClass="inputtext" property="username"/></td>
<td> </td>
<td>Web:</td>
<td> </td>
<td><html:text size="50" name="blogForm2" styleClass="inputtext" property="webaddress"/></td>
</tr>
<tr>
<td>Enter Code:</td>
<td> </td>
<td><html:text size="66" name="blogForm2" styleClass="inputtext" property="commentword"/></td>
<td> </td>
<td >Code:</td>
<td> </td>
<td><img src="<bean:write name="entry" property="commentpicurl" />"></td>
</tr>
<tr>
<td colspan="7">Comment<br><html:textarea name="blogForm2" styleClass="comment" property="comment" /></td>
</tr>
<tr>
<td colspan="7"><html:submit styleClass="inputtext" onmousedown="javascript:saveComment();"><bean:message key="button.save"/></html:submit></td>
</tr>
</table>
</p>
</div>
<div class="bottombig"></div>
</div>
</div>
</logic:notPresent>
<logic:present name="savedcomment">
<div id="writeblogcomment">
<div class="topbig">Comment saved<div class="headsmall">Kommentar gespeichert</div></div>
<div id="bginhaltwriteblogcomment">
<div class="breaker10" style="clear:left; "></div>
<div align="center">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td>Comment saved</td>
</tr>
</table>
</p>
</div>
<div class="bottombig"></div>
</div>
</div>
</logic:present>
</div>
</div>
<html:hidden name="blogForm2" property="formaction"/><br>
<html:hidden name="blogForm2" property="id"/><br>
<% session.removeAttribute("savedcomment"); %>
</html:form>
</body>
</html> -
Rest Service method called twice in wcf
Hi all,
I have created a rest service using wcf.
I am writing Entity framework code within a service method to fetch data from database.
Every call from browser is hitting the service method twice or thrice.
I found no exception within the method. I encountered same problem before and solved it adding DataContract attribute to all the models(not helping now).
What may be the possible reasons? Please help.
Regards
AshishHi,
I want to know if you are using the WebGet (Http GET). If so, please try to change that API to WebInvoke (Http POST).
Because IIS has some setting for HTTP GET as 40sec replay, so if within 40sec the server does not get response, then it will query itself again. Then it will be called twice or more.
For more information, please try to refer to:
#RESTful API in WCF get called more than one time:
http://www.codeproject.com/Tips/338142/RESTful-API-in-WCF-get-called-more-than-one-time-b .
Best Regards,
Amy Peng
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. -
LoginModule login method called twice on unsuccessful logins
This is a cross post of a topic in the Application Server - General forum. The login and abort methods of our JAAS LoginModule are called twice when authentication is unsuccessful. It is called once on successful logins. This is problematic as it puts the user closer to locking the user's network account. We have confirmed that this is an issue, perhaps resolvable, with the container itself - version 10.1.2.0.2. I recreated the problem with a simple web application and using Frank Nimphius' simple JAAS login module. Here's a snippet from the redirected out:
07/07/07 15:37:01 Enter login
07/07/07 15:37:01 Performing user authentication for user
07/07/07 15:37:01 User is not authenticated - Password must be "welcome"
07/07/07 15:37:01 Enter abort
07/07/07 15:37:01 Authentication Failed
07/07/07 15:37:01 Authentication: FAILED.
07/07/07 15:37:01 JAAS-OC4J: Authentication failure for user: user
07/07/07 15:37:01 Enter login
07/07/07 15:37:01 Performing user authentication for user
07/07/07 15:37:01 User is not authenticated - Password must be "welcome"
07/07/07 15:37:01 Enter abort
07/07/07 15:37:01 Authentication Failed
07/07/07 15:37:01 Authentication: FAILED.
07/07/07 15:37:01 JAAS-OC4J: Authentication failure for user: user
Has anyone else experienced this problem and found a workaround or setting to prevent this behavior?Follow-up: I ran the sample application and LoginModule using oc4j 10.1.3.2 and it appears that the problem is resolved. As moving to 10.1.3.2 might not be an option is there some patch to 10.1.2 to correct the issue?
-
EO Validation method called twice
Hi,
I have written an EO based field Validation method. But the problem is it is being called twice. First time ,it is validating correctly. But the second time it is not taking the field value and giving the error
I have included it like this in my jspx.
<af:inputText value="#{bindings.SubOrgName.inputValue}"
label="#{bindings.SubOrgName.label}"
required="#{bindings.SubOrgName.mandatory}"
columns="#{bindings.SubOrgName.displayWidth}"
binding="#{backing_Org.inputText3}"
id="inputText3"
rows="1">
<af:validator binding="#{bindings.SubOrgName.validator}"/>
</af:inputText>
Please help.Thanks for sharing! ;-)
-
Swing: actionPerformed method called twice
Hi All,
In a Swing application, is it correct to do as below piece of code, In a button click event handler call the actionPerformed method once again when the validation fails. Will it have any effects on the performance.
The reason for me to ask this is because my Swing application works fine for a level of time. Then suddenly starts to call the actionPerformed method twice without any reason for each button click event.
All I can suspect is the below piece of code. Pls help. Let me know if I am not clear.
button_actionPerformed(ActionEvent e) {
Actions .......
If(!Validate) {
button_actionPerformed(ActionEvent e);
}ActionListener is there only once
button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
try{
button_actionPerformed(e);
catch (Exception ex)
ex.printStackTrace();
}); -
EOImpl's prepareForDML called twice when PK is updated.
Hi,
I update the DeptNo to an unique number. The prepareForDML is called twice. Why does this happen?
thanks,
BuksHi,
I update the DeptNo to an unique number. The prepareForDML is called twice. Why does this happen?
thanks,
Buks -
Action Listener Method called multiple times
I have a page (fragment .jsff), containing a simple input text and a button called "search". When I click on "Search" the action listener is triggered multiple times. (The results are displayed in a table inside a panel collection).
The results are actually coming back ok.
When I debug the code, I can see the action listener method called twice.
Do you know why is that?
What should I be taking care of?
This is my code :
*** Fragment ****
<af:commandButton text="#{identityBundle.search_label}" id="cb1"
actionListener="#{UserDetailsBean.searchUsersListener}"
disabled="#{!bindings.searchUsers.enabled}"/>
*** Managed bean ***
public void searchUsersListener(ActionEvent actionEvent) {
// Add event code here...
DCBindingContainer bindings = (DCBindingContainer)getBindings();
DCIteratorBinding iter = bindings.findIteratorBinding("userIterator");
DCDataRow row = (DCDataRow)iter.getCurrentRow();
User user = (User)row.getDataProvider();
boolean isSearchCriteriaPresent = false;
if(user != null){
String fn = user.getFirstname();
if(fn != null && !fn.trim().equals("")){
isSearchCriteriaPresent = true;
user.setLastname(fn);
user.setNonMTUserLogin(fn);
try {
Map <Object, Object> userMap = PropertyUtils.describe(user);
for(Map.Entry<Object, Object> entry: userMap.entrySet()){
if(entry.getKey() != null && entry.getValue() != null && !entry.getKey().toString().equalsIgnoreCase("class")){
isSearchCriteriaPresent = true;
break;
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
if(!isSearchCriteriaPresent){
user.setFirstname("*");
OperationBinding opBinding = (OperationBinding)bindings.getOperationBinding("searchUsers");
opBinding.getParamsMap().put("user", user);
opBinding.execute();
AdfFacesContext adfFacesCtx = AdfFacesContext.getCurrentInstance();
Map<String, Object> scopePageFlowScopeVar= adfFacesCtx.getPageFlowScope();
scopePageFlowScopeVar.put("userSearchCriteria", user);
ADFContext adfCtx = ADFContext.getCurrent();
Map sessionScope = adfCtx.getSessionScope();
sessionScope.put("userSearchCriteria", user);
setUserSearchCriteria(user);
if(selectedUserID != null){
selectedUserID.setValue(null);
RichTable table = getUserResultsTable();
DCIteratorBinding searchUsersIterator = (DCIteratorBinding)bindings.get("searchUsersIterator");
Row[] rows = searchUsersIterator.getAllRowsInRange();
if(rows.length > 0){
RowKeySetImpl rks = new RowKeySetImpl();
ArrayList keyList = new ArrayList();
keyList.add(rows[0].getKey());
rks.add(keyList);
table.setSelectedRowKeys(rks);
table.setDisplayRowKey(keyList);
refreshState(table);
if(!isSearchCriteriaPresent){
user.setFirstname(null);
else{
deleteUserButton.setDisabled(true);
resetPasswordButton.setDisabled(true);
enableUserButton.setDisabled(true);
disableUserButton.setDisabled(true);
Thanks in advance for your helpHi,
Can you try this?
1. set partialSubmit=true for the "search" button
2. set "search" button id as partialTrigger in your result table
-Prasad -
How can i restrict code on prepareForDML method
Hi All,
In my use-case i have created one IMPL class for entity where i override prepareForDML() method and write some code.
this code executed when i change on approveStatus attribute on adf table and press commit button(from DC).
This is fine but problem is that now i change on other attribute of same vo claimed_by and press commit so prepareForDML() method call and same code executed again i don't want this want to bypass prepareForDML() method. or part of code not execute.
Regards
Manishyou can check if the desired attribute has been changed or not before executing your method
protected void prepareForDML(int i, TransactionEvent transactionEvent)
if(this.isAttributeChanged(YourAttributeIndex))
//execute your code
super.prepareForDML(i, transactionEvent);
} -
Hi,
I am having a ComboBox and when I select an Item, my listener calls twice.
cmbInputSource.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(ItemEvent e) {
setInputSource(cmbInputSource.getSelectedItem().toString());
});Thats my code, I am using this code in my Constructor, but I still dont find why this method calls twice.
Any Ideas?
ThnxGreat job ��we define this not a bug, but a feature :/
Or is anyone serious that it is good API design to make a method name look self-explanatory, but have an important detail hidden in the documentation?
The unnecccessary double call of event listeners may potentially decrease the perceived performance of the system by 50% ��this shouldn't be a favourite solution.
I searched the bug database for an "RFE" concerning this point, didn't find one. However I don't file one, as I don't have a simple test code at hand to demonstrate the problem.
Martin -
Method CreateChildren in ApplicationControllBar class called twice after setting dock=true
Hi during creating of a custom ApplicationControllBar
component in ActionScript I probably found a (nasty) bug?!
package net.neijman.julia.jaContainers
import mx.containers.ApplicationControlBar;
public class JAApplicationControlBar2 extends
ApplicationControlBar
public function JAApplicationControlBar2(): void
this.dock = true;
super();
override protected function createChildren(): void
trace("CREATECHILDREN EXECUTED");
When I am using my simple custom component in my application:
<jaContainer:JAApplicationControlBar2 />
The trace message trace("CREATECHILDREN EXECUTED"); is
executed twice (meaning CreateChildren is called twice BUT ONLY
AFTER SETTING dock = true (see constructor). When setting dock =
false CreateChildren is executed once. I want to build a framework
on the standard components (depending heavily on the
CreateChildren-method).
In other words, creating dynamic components in the docked
ApplicationControlBar in the method CreateChildren results in a
double placement in the DisplayList.
Has anyone has a clue what's going wrong here? (my
workarround for now is to start the createChildren method with
removeAllChildren();)
Thanks Tom NeijmanInteresting. I would file it as a bug here:
http://bugs.adobe.com/jira/secure/Dashboard.jspa
And then see what happens. If it's not a bug, you'll probably
get a decent reason why this occurs in the bug notes.
matt horn
flex docs -
Why listener methods are getting called twice ?
Hi Group,
I have a doubt, i need to know logic behind it.
Lets consider, JComboBox,
For an item state change of JComboBox,
itemStateChanged method gets called twice.
Its similar with valueChanged getting called twice
on List Selection Event.
Why does it call twice ? Is there any way, I can
have invocation only once (except flagging mechanism)?
with regards,
vikram.http://java.sun.com/j2se/1.3/docs/api/java/awt/event/ItemListener.html
tells the following:
public void itemStateChanged(ItemEvent e)
Invoked when an item has been selected or deselected. The code written for this method performs the operations that need to occur when an item is selected (or deselected).
So the listener is notified for both items: losing and gaining selection.
If you are only interested in listening to either selection or deselection event you can check which was the cause for the method call by examing the ItemEvent parameter i.e. item_event.getStateChange() == ItemEvent.DESELECTED or ItemEvent.SELECTED and then decide whether you are interested in the event at all.
I don't know how to stop JComboBox from launching both select and deselected events. -
Getter method being called twice
Hi All,
I have a h:inputText which updates a h:dataTable as soon as the user types something into it (through the use of Ajax4JSF's a4j:support element). In this way I have something similar to a suggestionbox, but which modifies the table underneath rather than displaying a dropdownlist with possible values. My problem is that for some reason the getter method in the managed request-scoped bean to which the h:dataTable is bound, is being called twice everytime a letter is typed into the h:inputText. The first call seems to happen directly after the bean has been constructed, as the value to which the h:inputText is bound is still empty, and the second call after that, but with the correct value obtained from the h:inputText.
I searched the forums and found posts detailing similar problems, but I couldn't find an explanation of why it happens or a way to get rid of it. The common consensus seems to be to not have any processing intensive operations in the getter and to just accept that it will be called twice.
Is there really no way around this?
Thank you,
RistrettoThis is just the default behaviour of the JSF lifecycle. The first call checks if there is a default value or a value which is been set in the previous request. The second call gets the newly set value for display which is been set during the request processing. A way to get rid of the first call might be writing your own lifecycle implementation.
-
DataAction prepareModel method getting called twice.
I have a DataAction subclass in which I have overridden the prepareModel() method, putting a System.out.println() into. I just discovered that this method is getting called twice per time that I run the DataAction. Why is this, and how do I change it so that it is only executed once?
BradHi:
The prepareModel method will get called each time your action is executed, ie before your page is displayed, and after a user submits a request.
If you dont want your code in the prepareModel method to be run when a user submits a request, you should check the event list. If the list is non-empty, then the user has submitted a request to your action.
The following code is taken from Steve Muench's ADFToyStore demo:
private boolean handlingEvents(DataActionContext ctx) {
List events = ctx.getEvents();
return (events != null) && (events.size > 0);
}in your prepareModel method, do the following:
protected void prepareModel(DataActionContext ctx) {
if(!handlingEvents(ctx)) {
// code for before the initial display of the page
} else {
// code to be executed before your event handlers get called
}HTH
Gareth
Maybe you are looking for
-
guys i need to display the open amount for the customer billing document see the below eg condider An invoice worth 1000 USD then say we receive a payment for 800, the open amount is 200. how can i get this open amount for customer billing documents
-
My display flickers slowly when coming out of sleep or booting up. After a short while the monitor works perfectly. After it goes into sleep mode, or when the screen saver goes dark, upon awakening the flicker starts again. I recently replaced my AT
-
Using taglib in web.xml in WLS 9.2
I am trying to build a web application in which the JSPs refer to a JSF taglib at the following URI(http://java.sun.com/jsf/core). When i deploy the application in WLS 9.2 and attempt to load this JSP, WLS says that it is unable to resolve this tagli
-
H264 rtmp poor video quality compared to VLC play
Hi! I have Flash Media Server 4. Video is and MP4 wrapped H264 at 2Mbps 720x576. Playing the video with VLC player or any other player the quality is fine and very good! Same file streamed from FMS4 (same on 3.5) with rtmp protocol has very poor qual
-
Cant use elluminate on Firefox MAC I need to Save the file to your desktop with a jnlp file extension, eg. Meeting.jnlp Right click or Control click on the JNLP file and select Open With -> Other In the "Choose Application" window, in the left panel,