I developed one swing application but each time you run application new window is opened.
I want that if one window is already opened other not allow to open.
I need a quick jump start for using Spring and Hibernate together and I was looking for some sample code to modify and extend. Bonus points for Struts2 and Spring Security integration.
Hi,
I was doing my academic project and while building and testing i have put many println() statements.
But when I had to submit all prints should not be displayed.
Can i implement something like listener which will be invoked when System.out is tried to be executed and prevents it from displaying.
I dont know how feasible this idea is but just want to know whether its possible or not.
I know i could have used a log file or write into a file but again its just a thought came into my mind if I have to disable SOP how can i do it ..
thanks
I've the same problem as described here
In the generated SQL Informix expects catalog:schema.table but what's actually generated is
catalog.schema.table
which leads to a syntax error.
Setting:
hibernate.default_catalog=
hibernate.default_schema=
had no effect.
I even removed schema and catalog from the table annotation, this caused a different issues : the query looked like that ..table same for setting catalog and schema to an empty string.
Versions
seam 2.1.2
Hibernate Annotations 3.3.1.GA.CP01
Hibernate 3.2.4.sp1.cp08
Hibernate EntityManager 3.3.2.GAhibernate
Jboss 4.3 (similar to 4.2.3)
I have an activity which pulls some JSON from my server, and then uses it to draw a list. That list launches further activities.
My problem is that I can't figure out a way to tell if the activity is still alive when you go back to it, so I end up re-querying my JSON from the server and redrawing the list every time the user goes back to the activity.
How can I tell if my activity is still alive so I can skip the redraw?
The code at the bottom is what I have. I removed the creation of all tags.
At the top in the xml file I get.<?xml version="1.0" encoding="UTF-8" standalone="no"?> Note that standalone is no, even thou I have it set to yes.
The first question: How do I get standalone = yes?
I would like to add <?xml-stylesheet type="text/xsl" href="my.stylesheet.xsl"?> at line two in the xml file.
Second question: How do I do that?
Some useful links? Anything?
DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = dbfac.newDocumentBuilder();
Document doc = docBuilder.newDocument();
<cut>
TransformerFactory transfac = TransformerFactory.newInstance();
transfac.setAttribute("indent-number", new Integer(2));
Transformer trans = transfac.newTransformer();
trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
trans.setOutputProperty(OutputKeys.STANDALONE, "yes");
trans.setOutputProperty(OutputKeys.INDENT, "yes");
trans.setOutputProperty(OutputKeys.CDATA_SECTION_ELEMENTS, "name");
FileOutputStream fout = new FileOutputStream(filepath);
BufferedOutputStream bout= new BufferedOutputStream(fout);
trans.transform(new DOMSource(doc), new StreamResult(new OutputStreamWriter(bout, "utf-8")));
What is the memory and performance usage compared to creating a object with only a constructor?
The usage here is in creating a Set<Object> or List<Object> that may contain million plus entries and I am concerned with the overhead of using Bloch's Builder Pattern. I have used it in the past, but never in this large of a scope.
I have downloaded ip-to-country.csv that has ip ranges that are mapped to countries. How should I store this data to database and how can I query in what range Ip address is to know where Ip address is coming from?
May be a dumb question, but GWT FlowPanel (raw div element) does not provides something to handle a mouseclick/mousemovement on it. Overriding onBrowserEvent do not works either.
If setting onclick event using native JavaScript (need to specify positive height before, 'div' have a height of 0 if not specified), then catching these events is working properly. Is there a way to do it without using JSNI?
How to make use of jndi in a stand-alone (non-managed) application?
App and Tomcat6 are on the same machine.
Can we get something through jndi lookup when the server is running,
but when the app is not running under this tomcat server?
Hi @all,
I have a class hierarchy / inheritance like this:
public class A {
private String name;
// with getters & setters
public void doAWithName(){
...
}
}
public class B extends A {
public void doBWithName(){
// a differnt implementation to what I do in class A
}
}
public class C extends B {
public void doCWithName(){
// a differnt implementation to what I do in class A and B
}
}
So at one time there is a instance of class A with the initialized field "name". Later I want this instance of A get wrapped into instance of B or C. So the superclasses should be get wrapped with a subclass!
How can I make this most efficent with respect to DRY?
I've thought about a constructor that does some copying with the getters/setters. But in this case I have to repeat myself - and this doesn't respect anymore to my initial requirement of DRY!
So, how can I warp A to B by just initializing B's new fields (with default values) and delegating the rest to a method in A (which knows more than B about which fields of A should be accessed...).
In the same way:
If A should be wrapped into C only a method in c should init C's 'new' fields, delegate to B's wrap method (which therefore inits B's 'new' fields in C) and at last B delegates to A which copies it's fields to the fields of C).
So in the end I have a new instance of C which has the values of A wrapped (and some default init values to the fields which the inheritance hierarchy has added).
I have been playing around a lot with the ExpandableListView and I cannot figure out where to add the button listeners for the button that will be the children in the view. I did manage to get a button listener working that uses getChildView() below, but it seems to be the same listener for all the buttons.
The best case scenario is that I would be able to implement the button listeners in the class that instantiates the ExpandableListAdapter class, and not have to put the listeners in the actual ExpandableListAdapter class. At this point I don't even know if that is possible
I have been experimenting with this tutorial/code: HERE
getChildView()
@Override
public View getChildView(int set_new, int child_position, boolean view, View view1, ViewGroup view_group1)
{
ChildHolder childHolder;
if (view1 == null)
{
view1 = LayoutInflater.from(info_context).inflate(R.layout.list_group_item_lv, null);
childHolder = new ChildHolder();
childHolder.section_btn = (Button)view1.findViewById(R.id.item_title);
view1.setTag(childHolder);
childHolder.section_btn.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
Toast.makeText(info_context, "button pushed", Toast.LENGTH_SHORT).show();
}
});
}else {
childHolder = (ChildHolder) view1.getTag();
}
childHolder.section_btn.setText(children_collection.get(set_new).GroupItemCollection.get(child_position).section);
Typeface tf = Typeface.createFromAsset(info_context.getAssets(), "fonts/AGENCYR.TTF");
childHolder.section_btn.setTypeface(tf);
return view1;
}
Any help would be much appreciated. Thank you and I will be standing by.
When signing an apk after a long break from Android development I was surprised that I'm no longer able to enter an empty keystore password to unlock it. Is it just me or has this been possible before? If so, when did that change and how can I manage to unlock the keystore anyway?
Some background: maybe I'm just crazy and didn't use an empty password for the keystore before, but the one and only possible password that I could have been using instead doesn't work either (I swear, there's no chance I'd have used another password!).
ATG (http://www.atg.com) is a frameowrk, a platform and a solution for content presentation and management, personalisation, e-commerce and customer relationship management.
Which free and open source frameworks or products would you recommend to replace the basic functionality it provides?
In the spirit of Stack Overflow, can you answer with one item in each answer and use the voting rather than duplicating someone else's answer.
I have started with some answers
I have taken over some code that has been using the Firestorm DAO code generator from CodeFutures. I believe that the license for this is going to be up soon, and was wondering if anyone could recommend any alternatives, open source or not, so that I can get an idea of what's out there to better make a decision.
Hi, I have a functioning app and recently have had intermittent
problems writing to the datastore. I did not make any relevant code
changes, however in the last few days my attempts to write to the
datastore sometimes work and sometimes don't.
I am trying to save an object that is in a many to one relationship
with an existing persisted parent. So, the logic works like this:
1) Parent pulled from the datastore
2) Child created / instantiated using constructor
3) Parent.addSingleChild(child); // the "addSingleChild" method
just adds the object argument to the collection of children
4) child.setParent(Parent); // sets the Parent object to the
parent field
I am using transactions as explained in the documentation ending with
"finally {if (tx.isActive()) {tx.rollback(); } }"
When the servlet is called, the parent is called from the datastore
and the child object is created and added to the many to one mapping
to the pre-existing parent.
The child should automatically be persisted, since the parent is
already persistent, and the child is added to the collection of
children that map to the parent. And it worked this way in the
past. However, to be sure, i did add a pm.makePersistent(child).
Doesn't seem to help, still have the intermittent problem.
Any suggestions would be appreciated, and if you need to see the
actual code I can post. Thanks
I have a SVG document that I exported from Visio 2003 that would like to edit. This file has an action where you click a button it will navigate to a new screen. What I would like to do is have the navigation be based off of a data point rather than having to click the button.
As an example I have a dynamic point data being brought into the SVG file and when that value changes from 0 to 1, I want this screen to automatically navigate to another screen. Below is the code I for clicking the button.
<title content="structured text">Sheet.1107</title>
<desc content="structured text">Button 1</desc>
<v:custProps>
<v:cp v:ask="false" v:langID="1033" v:invis="false" v:cal="0" v:val="VT4(Test Graphic 2)" v:type="0" v:prompt="" v:nameU="ObjRef" v:sortKey="" v:lbl="" v:format=""/>
<v:cp v:ask="false" v:langID="1033" v:invis="false" v:cal="0" v:val="VT4(SF-S)" v:type="0" v:prompt="" v:nameU="DataPt" v:sortKey="" v:lbl="" v:format=""/>
</v:custProps>
<v:userDefs>
<v:ud v:prompt="" v:nameU="NAVIGATE" v:val="VT4(NAVIGATE Test Graphic 2,'',)"/>
</v:userDefs>
<v:textBlock v:margins="rect(4,4,4,4)"/>
<v:textRect width="125.01" height="35" cx="62.5" cy="517.5"/>
<rect x="0" width="125" y="500" height="35" class="st3"/>
<text x="40.15" y="521.1" v:langID="1033" class="st4"><v:paragraph v:horizAlign="1"/><v:tabList/>Button 1</text> <jci:action type="click" count="1">if(evt.button == 0) nav('Test Graphic 2','','');</jci:action></g></a>
In the above code I am bringing in the data value from SF-S. Once that value is equal to 1 I want this screen to automatically navigate to Test Graphic 2.
I don't have any experience with coding so I am hoping someone here will be able to help me.
Thanks,
DMyers
I use netbeans,and I insert an image on the lable which is on the desktop pane ,I want to rotate that image in its place ,what should i do?
please help me.
thanks.
I have this code but the toast wont display any message what is wrong with my code.. I can get the value from link, linknext but title wont bring out any value. ( I am not very bright with writing code so please suggest anything you may feel like.
final Button button = (Button) findViewById(R.id.Button01);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Perform action on click
try {
URL url = new URL(
"http://somelink.com=" + Link.setFirst_link);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(new InputSource(url.openStream()));
doc.getDocumentElement().normalize();
NodeList nodeList = doc.getElementsByTagName("item");
/** Assign textview array lenght by arraylist size */
for (int i = 0; i < nodeList.getLength(); i++) {
Node node = nodeList.item(i);
Element fstElmnt = (Element) node;
NodeList nameList = fstElmnt.getElementsByTagName("link");
Element nameElement = (Element) nameList.item(0);
nameList = nameElement.getChildNodes();
String img = (((Node) nameList.item(0)).getNodeValue());
NodeList websiteList = fstElmnt.getElementsByTagName("linknext");
Element websiteElement = (Element) websiteList.item(0);
websiteList = websiteElement.getChildNodes();
String nextlink = (((Node) websiteList.item(0)).getNodeValue());
Link.setFirst_link = nextlink;
Drawable drawable = LoadImageFromWebOperations(img);
imgView.setImageDrawable(drawable);
NodeList titleList = fstElmnt.getElementsByTagName("title");
Element titleElement = (Element) titleList.item(0);
websiteList = titleElement.getChildNodes();
String title = (((Node) titleList.item(0)).getNodeValue());
Context context = getApplicationContext();
CharSequence text = title;
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
}
} catch (Exception e) {
System.out.println("XML Pasing Excpetion = " + e);
}
}
});
/** Set the layout view to display
*/
}
Here is the xml file
<?xml version="1.0"?>
<maintag>
<item>
<link>http://image.com/357769.jpg?40</link>
<linknext>http://www.image.com</linknext>
<title>imagename</title>
</item>
</maintag>
I was going through the interview questions and found out the below question which I am not able to answer it. Can anyone provide some sort of algorithm for this problem how can I solve it?
There are a cluster of stateless servers all serving the same pages.
The servers are hosting 5 web pages- p1.html, p2.html, p3.html, p4.html and p5.html
p1.html just redirects users to the other 4 pages
Requests to p1.html should result in 10% of users being redirected to p2.html, 5% of users redirected to p3.html, 20% of users redirected
to p4.html, and 65% of users redirected to p5.html.
Users do not need to stick to the page they are first redirected to. They could end up on a different page with every request to
p1.html
Write a function/pseudocode that would be invoked with every request to p1.html and redirect the correct percentage of users to the
correct page.
Any suggestions will be of great help.
I am writing a tomcat app, and have a need to do authentication within the URL like this:
https://user:[email protected]
Except for the life of me i'm not sure how to set it up or able to find the docs to read up on it, clearly my google skills need work.
Can anyone tell me where i should be looking for this kind of info or where to start?
Cheers
Andy
Hello, I need to create something like internal frame in netbeans platform, which loads file from any location.
I tried it by jInternalFrame, but I was not able to find some container to which I can add my frame. I am working in netbeans platform, which has own pre-created main window.
Pease help me by any advice, I am dealing with this about 10 hours, still without result.
Is it possible to: set a URI template in the mvc:view-controller element of the *-servlet.xml file or in a controller method and then use/get that path parameter in a jsp?
I understand that using @PathVariable in a controller method will give me access to the path parameter in that controller method. But how can I gain access to the path parameter in the jsp?
For example, is it possible to do something like:
*-servlet.xml file:
<beans...>
<mvc:view-controller path="/home" view-name="home"/>
<mvc:view-controller path="/home/{error}" view-name="home"/>
</beans>
jsp file:
<c:if test="${not empty param['error']}">
<span class="error">You have an error...</span>
</c:if>
Hi all, im new in hibernate and JPA and i have some problems with annotations.
My target is to create this table in db (PERSON_TABLE with personal-details)
ID ADDRESS NAME SURNAME MUNICIPALITY_ID
First of all, i have a MUNICIPALITY table in db containing all municipality of my country.
I mapped this table in this ENTITY:
@Entity
public class Municipality implements Serializable {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;
private String country;
private String province;
private String name;
@Column(name="cod_catasto")
private String codCatastale;
private String cap;
public Municipality() {
}
...
Then i make an EMBEDDABLE class Address containing fields that realize a simple address...
@Embeddable
public class Address implements Serializable {
@OneToOne(cascade=CascadeType.ALL)
@JoinColumn(name="id_municipality")
private Municipality municipality;
@Column(length=45)
private String address;
public Address() {
}
...
Finally i embedded this class into Person ENTITY
@Entity
public class Person implements Serializable {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;
private String name;
private String surname;
@Embedded
private Address address;
public Person() {
}
...
All works good when i have to save a new Person record, in fact hibernate creates a PERSON_TABLE as i want, but if i try to retrieve a Person record i have an exception.
HQL is simply "from Person"
The excpetion is (Entities is the package containing all classes above-mentioned):
org.hibernate.AnnotationException: @OneToOne or @ManyToOne on Entities.Person.address.municipality references an unknown entity: Entities.Municipality
Is the @OneToOne annotation the problem?
Thanks.
I have the following code in a listener method:
FacesContext.getCurrentInstance().getExternalContext().getRequestMap().put("time", new Date());
When a button is clicked the following code is executed
System.out.println(FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("time"));
One could except that "time" is null when the listener was not executed while processing the current request, but: it seems like the "time" object survives the request processing. So when "time" has been set sometimes in the past it stays there... can anybody explain this? Thanks.