How to suppress Spinner double clickable problem of Android.
Try launch any application that having Spinner.
Then double tap it.
It will show context menu twice.
I working in a spring application which have an action method that returns a CSV file.
This action works fine but in some cases it throws a predefined exception (MyAppException).
I have another method that is annotated @ExceptionHandler(MyAppException.class)
In the exception handler method I return another csv file but with different contents.
The code that returns the csv file is almost the same in the two methods.
List<String[]> list= new ArrayList<String[]>();
list.add(new String[]{
integrationRequestErrorLog.getErrorMessage(),
Long.toString(integrationRequestErrorLog.getId()),
Integer.toString(integrationRequestErrorLog.getErrorCode())
});
CSVWriter writer = new CSVWriter(response.getWriter(), ',');
writer.writeAll(list);
writer.close();
the difference between the two method is the list of contents.
In the first method the file is returned normally while in the exception handler method I have a strange behavior.
The exception handler method works fine with Opera browser while it gives me a 404 with FireFox.
Opera browser give me 404 also but it download the file while firefox does not?
Really I do not understand what is the difference here.
Hi All,
i have the following code .
and in Form is have property called isActive of type char ,how would i get the checked value of it ,i am getting some symbols like 'o' if checked.
I am using userform.getIsActive() ,where i am going wrong .I want 'y' or 'n' values
Is is possible to use Tuckey's URL Rewrite to rewrite to a different Tomcat instance?
I have it working using crossContext="true" rewriting to a different servlet on the same tomcat instance, but our production server has multiple tomcat instances running and I want to rewrite to one of them instead?
If it's not possible using the URL Rewrite filter, is there another way of doing it?
Thanks.
I'm usin such code to generate contents file.
try {
StreamResult result = new StreamResult();
TransformerFactory tf = TransformerFactory.newInstance();
for (String item: groups){
item = item.replaceAll(" ", "-").toLowerCase();
result.setOutputStream(new FileOutputStream(path+item+".html"));
Templates templ = tf.newTemplates(xsltSource);
Transformer transf = templ.newTransformer();
transf.clearParameters();
transf.setParameter("group", item);
transf.transform(xmlSource, result);
}
} catch (TransformerConfigurationException e) {
throw new SinkException(e.getMessage());
} catch (TransformerException e) {
throw new SinkException(e.getMessage());
}
But on second iteration I have an exception
ERROR: javax.xml.transform.TransformerException: com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: Read error
Cann't understand what is the reason?
I am writing an eclipse plugin. How do I get the various images from eclipse library? So I don't have have keep a local set of images for the standard entities, e.g classes, interfaces, junits, etc.
EDIT : I used PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FILE) from the article : http://www.eclipse.org/articles/Article-Using%20Images%20In%20Eclipse/Using%20Images%20In%20Eclipse.html.
That did not work.
Whats the most efficient way to lower case every element of a list or set?
My idea for a List:
final List<String> strings = new ArrayList<String>();
strings.add("HELLO");
strings.add("WORLD");
for(int i=0,l=strings.size();i<l;++i)
{
strings.add(strings.remove(0).toLowerCase());
}
is there a better, faster way? How would this exmaple look like for a set? As there is currently no method for applying an operation to each element of a set (or list) can it be done without creating an additional temporary set?
Something like this would be nice:
Set<String> strings = new HashSet<String>();
strings.apply(
function (element)
{ this.replace(element, element.toLowerCase();) }
);
Thanks,
I used Collections.sort(playersList); to sort a list. So, I think playersList is sorted now. But how can I get the first element of the list? playersList[0] does not work.
Anyone have a good solution for scraping the HTML source of a page with content (in this case, HTML tables) generated with Javascript?
An embarrassingly simple, though workable solution using Crowbar:
<?php
function get_html($url) // $url must be urlencode(d)
{
$context = stream_context_create(array(
'http' => array('timeout' => 120) // HTTP timeout in seconds
));
$html = substr(file_get_contents('http://127.0.0.1:10000/?url=' . $url . '&delay=3000&view=browser', 0, $context), 730, -32); // substr removes HTML from the Crowbar web service, returning only the $url HTML
return $html;
}
?>
The advantage to using Crowbar is that the tables will be rendered (and accessible) thanks to the headless mozilla-based browser. The problem, of course, is being dependent on on an external web service, especially given that SIMILE seems to undergo regular server maintenance. :(
A pure php solution would be nice, but any functional (and reliable) alternatives would be great.
I have a POJO that is similar to:
public class MyGsonPojo {
@Expose
@SerializedName("value1")
private String valueOne;
@Expose
@SerializedName("value2")
private boolean valueTwo;
@Expose
@SerializedName("value3")
private int valueThree;
// Getters and other stuff here
}
The issue is that this object has to be serialized into a json body for a call
to the server. Some fields are optional for the request and if I even send it with default and null values, the API responds differently (Unfortunately changing the api is not an option).
So basically I need to exclude fields from serialization if any of them is set to a default value. For example if the field valueOne is null the resulting json should be:
{
"value2" : true,
"value3" : 2
}
Any idea how to make this a painless effort? I wouldn't want to build the json body manually.
Any help would be great. Thank you in advice.
I have a small problem about a content returning from servlet to put in table cell.
In javascript I am calling servlet method using post, it returns some content and I have to put it in two different <td> cells. here is my code,
In javascript,
$.post('<%=request.getContextPath()%>/controller/UserLockController',{'userName':userName,'status':status},
function(data)
{
document.getElementById("status_"+userName).innerHTML=data;
document.getElementById("td_"+userName).innerHTML=data;
});
in servlet it writes as,
out.println("<td id=\"status_"+inputParam+"\">Locked</td>");
out.println("<td id=\"td_"+inputParam+"\"><a href=\"#\" class=\"btn btn-sm btn-primary unlockBtn\" id=\"togBtn_"+inputParam+"\" onClick=\"LockAccount('"+inputParam+"','"+status+"')\">UnLock</td>");
Here content is returning but problem is the both <td> return from servlet will fit in single cell of html table. how to solve this please help me.
I am having a sorted list which is rotated and I would like to do a binary search on that list to find the minimum element.
Lets suppose initial list is {1,2,3,4,5,6,7,8}
rotated list can be like {5,6,7,8,1,2,3,4}
Normal binary search doesn't work in this case. Any idea how to do this.
I'm using Eclipse Juno to create jax-ws webservice on WebSphere® Application Server V8.5 Tools. The WebService sometimes are created but most often he fails to create wsdl. For exemplify, i try to create a simple webservice named Web:
import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService
public class Web {
@WebMethod
public String getName() {
return "myName";
}
}
After deploy this webservice and viewing WebSphere administration page not exists any service named WebService. I tried too access the generated WebSphere wsdl from the url localhost:9080/MyProject/WebService/WebService.wsdl but this not exists.
My project have a configured MANIFEST file that contains:
Manifest-Version: 1.0
UseWSFEP61ScanPolicy: true
I'm actually using servlet 3.0 but tried with 2.3. Anyone can help me to do WebSphere approprieate scan annotations of ws-jax and create wsdl on server?
i use the following method to send email to list of users
i want the (To) in each email to be for just the user only not all users
i.e appears to the users that the email is sent to only him
my guess is to loop on:
message.addRecipients(Message.RecipientType.TO, address);
then send the message right? , but this is a heavy process sending an email many times
any ideas ?
suppose that i have the timezone for each user and i want to send each user the message in his timzone, the same issue i guess setting sent date for each user in his timezone then sending the message, right ?
the method is:
try {
Properties props = System.getProperties();
props.put("mail.smtp.host", "localhost");
// Get a mail session
Session session = Session.getDefaultInstance(props, null);
// Define a new mail message
Message message = new MimeMessage(session);
InternetAddress ia = new InternetAddress();
ia.setPersonal("MySite");
ia.setAddress(from);
message.setFrom(ia);
Address[] address = new Address[recievers.size()];
for (int i = 0; i < recievers.size(); i++) {
address[i] = new InternetAddress(recievers.get(i));
}
message.addRecipients(Message.RecipientType.TO, address);
message.setSubject(subject);
// Create a message part to represent the body text
BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setContent(body, "text/html");
// use a MimeMultipart as we need to handle the file attachments
Multipart multipart = new MimeMultipart();
// add the message body to the mime message
multipart.addBodyPart(messageBodyPart);
// Put all message parts in the message
message.setContent(multipart);
message.setSentDate(getCurrentDate());
// Send the message
Transport.send(message);
} catch (Exception ex) {}
While looking through the Selenium source code I noticed the following in the PageFactory:
public static <T> T initElements(WebDriver driver, Class<T> pageClassToProxy) {
T page = instantiatePage(driver, pageClassToProxy);
initElements(driver, page);
return page;
}
public static void initElements(WebDriver driver, Object page) {
final WebDriver driverRef = driver;
initElements(new DefaultElementLocatorFactory(driverRef), page);
}
What is the benefit of having the following line?
final WebDriver driverRef = driver;
Wouldn't it have made sense to just make the parameter final, and then passing that along to the next method without declaring the new reference?
Consider the following output from a Tomcat server under Eclipse:
INFO: Initializing Coyote HTTP/1.1 on http-8080
INFO: Initialization processed in 634 ms
INFO: Starting service Catalina
INFO: Starting Servlet Engine: Apache Tomcat/6.0.20
SEVERE: Error listenerStart
SEVERE: Context [/MyServlet] startup failed due to previous errors
I would like to figure out what exception caused "Error listenerStart", but Spring seems to be preventing me from finding the error via Eclipse. I'd love to start Catalina manually, but that doesn't seem to do anything.
What's the best way to find the hidden exception? I'm not afraid to use torture methods.
We are getting frequent out of memory errors in our dev. machines We are running webshpere, eclipse, soap UI and maven in it. Our server gets down due to this "out of memory errors" when we restart our applications in websphere 2/3 times, We already increased the virtual memory setting in wesphere to 1GB.
So what i did was copied the jre we use in eclipse and maven folders so that each of these uses individual jvms. But the performance of websphere is same. 2/3 restarts and out of memory errors.
Is there any may of making eclipse and maven use different jvms other than websphere's?
This is my below code, I am confuse why this thing is happening. In this code getLocationByIpTimeout is a method in which I am passing two things- one is the ip address and second is the timeout. So I will get the timeout exception if the response is not getting back in under 5 ms. So when I ran this below code, I am getting few timeout exceptions but the most important thing that I am confuse is if I am getting timeout exceptions (time taken to get the response is greater than 5 ms) then why the program is entering in that if loop in which I am having difference 5. What can be the possible reason for this? It is because of catch block?? Any suggestions will be appreciated.
long runs =10000;
long difference = 0;
while(runs > 0) {
String ipAddress = generateIPAddress();
long start_time = System.nanoTime();
try {
resp = PersonalizationGeoLocationServiceClientHelper.getLocationByIpTimeout(ipAddress, 5);
} catch (TimeoutException e) {
System.out.println("Timeout Exception");
}
long end_time = System.nanoTime();
if(resp == null || (resp.getLocation() == null)) {
difference = 0;
} else if(resp.getLocation() != null) {
difference = (end_time - start_time)/1000000;
}
if(difference> 5) {
System.out.println("Debug");
}
}
I cannot figure out a way to disable a container AND its children in Swing. Is Swing really missing this basic feature?
If I do setEnabled(false) on a container, its children are still enabled.
My GUI structure is pretty complex, and doing a traversion of all elements below the container is not an option. Neither is a GlassPane on top of the container (the container is not the entire window).
How can i programmatically get the names of all tables in a JavaDB database? Is there any specific SQL-statement over JDBC I can use for this or any built in function in JDBC?
I will use it for exporting the tables to XML, and would like to do it this way so I don't miss any tables from the database when exporting.
I need show/hide some fields of my panel, and I want the panel to fit the frame. How could I notify to the parent frame to revalidate?
I think in pass the frame to my panel's constructor, but I think may have a way this is already done. I remember that there was a protected attribute in JPanel, but there isn't.. maybe i remembering the wrong component.
Can someone give a good suggestions of an excellent tutorial on org.apache.http.client.HttpClient
I tried this one but it does not cover a lot of details about the params etc.
http://hc.apache.org/httpclient-3.x/tutorial.html
For some reason Hibernate seems to be keeping my session open and updating the object without me explicitely invoking a save/update/saveorupdate. I guess the session is staying open and it's beeing marked as dirty.
However this is not the desired behaviour, so what's the cleanest way to fix this?
The issue seems to occur because I store a phone number without formatting in the database but the getter of the object returns a formatted telephone number.
My flow:
go to a jsp = controller = service = dao
DAO getter function
if(userId != 0) {
return (User)dbFactory.get(User.class, userId);
}
return null;
The service just passes it to the controller and the controller puts te User object in the request scope. I display it on my JSP page using EL.
could someone explain why this code output is
not equals
not equals 2
in the first if statement it seems that a = 0 b/c is a postfix increment; therefore a will not increase untile next line; however, the two a's are not equal why? and in the second if when I run the debugger the value of a is 2, but the test is false, why?
public static void main (String[] args)
{
int a = 0;
if (a++ == a++) {
System.out.println("equals");
} else {
System.out.println("not equals");
}
if (++a == 2) {
System.out.println("equals 2");
} else {
System.out.println("not equals 2");
}
}