I have a domain object that holds results of a calculation based on parameters that are properties of the same domain object. I'd like to make sure that any time parameters get changed by the user, it recalculates and gets saved properly into the database.
I am trying to do that with afterInsert (to make sure calculation is correct in the first place), and afterUpdate.
However, since my calculation is trying to modify the object itself, it's not working - throwing various hibernate exceptions.
I tried to put the afterUpdate code into a transaction, but that didn't help. I am afraid I am getting into a circular dependency issues here.
The exception I am getting right now is:
org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [esc.scorecard.PropertyScorecard#27]
Are the GORM events designed for simpler use cases? I am tempted to conclude that modifying the object you are in the middle of saving is not the way to go.
Am facing issue in accessing the JSON object :
JSON Object am receiving is :
{"71":"Heart XXX","76":"No Heart YYYY"}
I tried to get the value of 71 and 72 separately and use it ...
but am getting some compile time issue as :
Syntax error on token ".71", delete this token
Code:
var map=$("#jsonText").val();
alert(map);
var obj=jQuery.parseJSON(map);
alert("JSON ::"+obj.71);
If am printing obj , am able to view [Object Object]
Can any one out there please help me to find the mistake i did ..I know the question above is asked in many threads in SO . Below are the few threads i found , but failed when i attempted to implement it ..
jquery json parsing
Also tried using the Jquery tutorial given in
Jquery JSON
Its working fine if the key is a String but getting the above error if its a number ...
Hello,
Is there a command in java for conversion of an ArrayList into a object array. I know how to do this copying each object from the arrayList into the object array, but I was wondering if would it be done automatically.
I want something like this:
ArrayList<TypeA> a;
// Let's imagine "a" was filled with TypeA objects
TypeA[] array = MagicalCommand(a);
I need to set a text area in the html template and use it as a custom component in vaadin the html snippet is as below
<table>
<tr>
<td>
JUNK SENTENCE
</td>
<td>
<div location="HEADIN"></div>
<div location="Details"></div>
<div location="Attachment"></div>
</td>
<td>
<p>School of more than 50 students univer versities.</p>
</td>
</tr>
</table>
All the place holders are working and displays data but the "details" holder should be a text area.
as the text is a lot over there so I tried the below way but it just turned the place holder to text vaadin could not manipulate / identify the "Details" place holder.
I tried the below way i set - in side the text area tag.
<textarea rows="4" cols="50">
</textarea>
and again i tried this way too which also did not work.
<textarea rows="4" cols="50" location="Details">
</textarea>
Any guidance would be appreciated to solve this
I am setting the needed values from a formfeildfactory and these values are set by implementing the Vaadin Custom field class(in case it helps some more to identify)
Hi All ,
I wanted know how the kernel is providing memory for simple C program .
For example :
#include<stdio.h>
#include<malloc.h>
int my_global = 10 ;
main()
{
char *str ;
static int val ;
str = ( char *) malloc ( 100 ) ;
scanf ( "%s" , str ) ;
printf( " val:%s\n",str ) ;
}
See, In this program I have used static , global and malloc for allocating dynamic memory
So , how the memory lay out will be ... ?
Any one give me url , which will have have details information about this process..
I am using Eclipse Helios with PDT, and when I am editing JavaScript files with the default JavaScript Editor (JSDT), code highlighting (Mark Occurrences) is not working for half of the code, for example JSON-style (or Object Literal if you will) declarations.
Little example:
Foo = {};
Foo.Bar = Foo.Bar || {};
Foo.Bar = {
bar: function(str) {
alert(str)
},
baz: function(str) {
this.bar(str); // This bar *is* highlighted though
}
};
Foo.Bar.baz('text');
No Bar, bar or baz is highlighted. For now, I humbly edit the JavaScript part of projects in Notepad++ because it just highlights every occurrence of whatever is currently selected.
Is there a common practice for Eclipse JavaScript developers to get code highlighting work correctly, using the popular Object Literal notation? An option or update I missed?
-update-
I have found that code highlighting depends on the code being properly outlined. Altough commonly used, Object Literal outlining still seems rare in javascript editors. the Spket Javascript Editor does partial Object Literal outlining, and the Aptana Javascript Editor does full Object Literal outlining. But both loses other important functionality. A quest for the editor with the least loss of functionality is currently in progress in this question.
Hi All,
What LayoutManager should I use to achieve a transposed version of FlowLayout?
Essentially, I want a vertical list which occupies multiple columns if it can't fit all of it's components within one column.
+------------------------+
| item 1 |
| item 2 |
| item 3 |
| item 4 |
| item 5 |
| item 6 |
| item 7 |
| item 8 |
+------------------------+
or
+------------------------+
| item 1 item 7 |
| item 2 item 8 |
| item 3 |
| item 4 |
| item 5 |
| item 6 |
+------------------------+
I want to fetch the id of a one-to-one relationship without loading the entire object. I thought I could do this using lazy loading as follows:
class Foo {
@OneToOne(fetch = FetchType.LAZY, optional = false)
private Bar bar;
}
Foo f = session.get(Foo.class, fooId); // Hibernate fetches Foo
f.getBar(); // Hibernate fetches full Bar object
f.getBar().getId(); // No further fetch, returns id
I want f.getBar() to not trigger another fetch. I want hibernate to give me a proxy object that allows me to call .getId() without actually fetching the Bar object.
What am I doing wrong?
A C++ class I'm writing uses shared_from_this() to return a valid boost::shared_ptr<>. Besides, I don't want to manage memory for this kind of object.
At the moment, I'm not restricting the way the user allocates the object, which causes an error if shared_from_this() is called on a stack-allocated object.
I'd like to force the object to be allocated with new and managed by a smart pointer, no matter how the user declares it. I thought it could be done through a proxy or an overloaded new operator, but I can't find a proper way of doing that.
Is there a common design pattern for such usage? If it's not possible, how can I test it at compile time?
I have an object tag in a HTML file:
<object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95">
<param name="FileName" value="../ABC/WildLife.wmv" id="mediaPlayerFile">
<param name="AutoStart" value="false" />
</object>
I want to change the filename using javascript.
What I have so far is this:
<script type="text/javascript">
function disp_current_directory() {
var val = document.getElementById('mediaPlayerFile');
val.attributes['value'].value = "D:\XYZ\WildLife.wmv";
}
</script>
But this doesn't work. :(
Is it possible? If yes, how?
I am trying to create a script that finds the closest store/location to a customer using googlemapsAPI. So I've got a json object which is a collection of store objects. Using Jquery's .each to iterate through that object, I am grabbing the driving time from the customer to each store. If it finds the directions, It copies the duration of the drive which is an object with the time in seconds and a human readable value. That appears to work, however when I try to sort through all of those store objects with the drivetime added, I cannot read the object copied from google. If I console.log the whole object, 'closest_store', It shows the values I'm looking for. When I try to read the values directly via closest_store.driveTime, Firebug is outputting undefined in the console. What am I missing here?
$.getJSON('<?php echo Url::base() ?>oldservices/get_locations', {}, function(data){
$.each(data, function(index, value)
{
var end = data[index].address;
var request = {
origin: start,
destination: end,
travelMode: google.maps.DirectionsTravelMode.DRIVING
};
directionsService.route(request, function(response, status)
{
//console.log(response);
if (status == google.maps.DirectionsStatus.OK)
{
value.driveTime = response.trips[0].routes[0].duration.value;
//console.log(response.trips[0].routes[0].duration.value);
};
});
});
var closest_store;
$.each(data, function(index, current_store)
{
if (index == 0)
{
closest_store = current_store;
}
else if (current_store.driveTime.value < closest_store.driveTime.value)
{
closest_store = value
};
console.log(current_store.driveTime);
}
)
});
I'm struggling with calling a virtual function in C++.
I'm not experienced in C++, I mainly use C# and Java so I might have some delusions, but bear with me.
I have to write a program where I have to avoid dynamic memory allocation if possible. I have made a class called List:
template <class T> class List {
public:
T items[maxListLength];
int length;
List() {
length = 0;
}
T get(int i) const {
if (i >= 0 && i < length) {
return items[i];
} else {
throw "Out of range!";
}
};
// set the value of an already existing element
void set(int i, T p) {
if (i >= 0 && i < length) {
items[i] = p;
} else {
throw "Out of range!";
}
}
// returns the index of the element
int add(T p) {
if (length >= maxListLength) {
throw "Too many points!";
}
items[length] = p;
return length++;
}
// removes and returns the last element;
T pop() {
if (length > 0) {
return items[--length];
} else {
throw "There is no element to remove!";
}
}
};
It just makes an array of the given type, and manages the length of it.
There is no need for dynamic memory allocation, I can just write:
List<Object> objects;
MyObject obj;
objects.add(obj);
MyObject inherits form Object. Object has a virtual function which is supposed to be overridden in MyObject:
struct Object {
virtual float method(const Input& input) {
return 0.0f;
}
};
struct MyObject: public Object {
virtual float method(const Input& input) {
return 1.0f;
}
};
I get the elements as:
objects.get(0).method(asdf);
The problem is that even though the first element is a MyObject, the Object's method function is called. I'm guessing there is something wrong with storing the object in an array of Objects without dynamically allocating memory for the MyObject, but I'm not sure.
Is there a way to call MyObject's method function? How? It's supposed to be a heterogeneous collection btw, so that's why the inheritance is there in the first place.
If there is no way to call the MyObject's method function, then how should I make my list in the first place?
When I run the following, I noticed spacing between nodes; My research revealed that -
1) If I do not add any text to win1 via setwininfo, then there is no problem.
2) When I include this code in a larger app, and when a button click is reveived from some where else, mysteriously the spacing gets corrected.
3) I tried binding the win1 & win2 nodes to content of scene - but no luck.
def mainframew : Integer = 250;
def mainframeh : Integer = 500;
class CtrlWindow extends CustomNode {
var wininfo : String;
var fsize : Integer;
var width : Integer;
public function setWinInfo(info : String) {
wininfo = info;
}
override protected function create () : Node {
var win = Group {
content: [
VBox {
content: [
Text {
font : Font {
size: fsize
}
content : bind wininfo
textAlignment : TextAlignment.CENTER // did not work
}
]
}
Rectangle {
width: width, height: 25
fill: Color.TRANSPARENT
strokeWidth : 2
stroke : Color.SILVER
}
]
}
return win;
}
}
public function run(args : String[]) {
var win1 = CtrlWindow{fsize:14, width:mainframew};
var win2 = CtrlWindow{fsize:14, width:mainframew};
win1.setWinInfo("The spacing between these nodes");
win2.setWinInfo("corrects itself after receiving an event");
Stage {
title : "MyApp"
scene: Scene {
width: mainframew
height: mainframeh
content: [
VBox {
spacing: 0
content: [
HBox {
content: win1
}
HBox {
content: win2
}
]
}
]
}
}
Hi,
I have an address control which display the contact info of the person.
so it displays something like
1234, street
City, CA 12345
Now i want to give user flexibility to create format out of it.
For ex someone might want to display address as,
street, City, Country
OR
Just display their emails:
[email protected][email protected]
Any good ideas on how to it or similar examples?
thanks
I'd like to use jQuery mobile on my desktop page.
I'm probably thinking of this wrongly, but I tried simply inserting a page element into an existing standard div, like this:
<body>
<div id="left_sidebar"> [...] </div>
<div id="mylist" data-role="page">
<div data-role="listview"> [list items bla bla] </div>
</div>
<div id="right_sidebar"> [...] </div>
<div id="site_footer"> (c) bla blub </div>
</body>
...hoping that only the middle part displays the "mobile" page elements.
However, that page div seems to override the entire site and turns the whole body into a mobile page (albeit displaying my listview item nicely... across the entire screen).
Any idea what to do?
Advice is much appreciated.
Learning C++ and see the class laid out like this:
class CRectangle {
int x, y;
public:
void set_values (int,int);
int area () {return (x*y);}
};
void CRectangle::set_values (int a, int b) {
x = a;
y = b;
}
I know Java and methods(functions) in Java are written within the class. The class looks like a Java interface. I know I can write the class like this:
class CRectangle {
int x, y;
public:
void set_values (int a, int b) {
x = a;
y = b;
};
int area () {return (x*y);}
};
But is there a difference or standard?
The reason I'm asking is because I'm getting NullPointerException.
I now this is very easy but I'm pretty new programming and find this a bit confusing.
So say I have initialized an object in a class and want to access that same object from another class.
Like now for instance I'm working on a small Chess game, in my model Game class I have an instance of Board, an object. Board, in turn, has an array of Squares. Square[][].
Game has board, board has Square[][].
Now if I want to access the Square[][] through the object board (in Game) of type Board.
Do I just declare a variable with the same name and type or do I have to initialize it again?
Board board OR Board board = new Board();
Note, I have already initialized board in the class Game so if I do it again, won't they be two totally different Board objects?
Guys, help me clarify.
Say i have the following line in my program:
jobSetupErrors.append("abc");
In the case above where jobSetupErrors is a StringBuilder(), what i see happen is:
New String Object is created and assigned value "abc"
value of that String object is assigned to the existing StringBuilder object
If that is correct, and I add 1 more line ...
jobSetupErrors.append("abc");
logger.info("abc");
In the above example are we creating String object separately 2 times?
If so, would it be more proper to do something like this?
String a = "abc";
jobSetupErrors.append(a);
logger.info(a);
Is this a better approach? Please advise
I developed a C# web application that calls a web-service which returns a base64 encoded array (PDF file). I then convert that array into a UCOMIStream object (I know it is obsolete, but the DLL that I am using requires it as a parameter). I use the following code to do the conversion which works perfectly. I can pass this object to the DLL so that I can print the PDF.
This works great on the Webserver, but the requirement is to print it locally.
Byte[] bBuffer = statementOut.statementcycle.statementdata.content;
int size = bBuffer.Length;
IntPtr mem = Marshal.AllocHGlobal(size);
Marshal.Copy(bBuffer, 0, mem, size);
// Create an OLE Stream object.
System.Runtime.InteropServices.UCOMIStream str; //obsolete but the createstreamonhglobal outputs it
CreateStreamOnHGlobal(mem, true, out str);
The DLL resides on the client so I am able to use ActiveX to create the object using javascript and/or VBscript;however, I have not been able to figure out how to get the stream object to the client to pass to the DLL.
How can this be achieved?