|
Hey working on an Android app with Zendesk SDK integration I need to do a simple HTTP POST request with basic authentication so I can get a user token back from a ASP script I'm hosting on IIS but I cannot for the life of me get it going. Every single example I see is somehow outdated even when I try to import the libraries they are using can anyone point me towards a good resource to get this done?
|
# ? Dec 14, 2015 21:04 |
|
|
# ? Jun 12, 2024 21:08 |
|
socialsecurity posted:Hey working on an Android app with Zendesk SDK integration I need to do a simple HTTP POST request with basic authentication so I can get a user token back from a ASP script I'm hosting on IIS but I cannot for the life of me get it going. Every single example I see is somehow outdated even when I try to import the libraries they are using can anyone point me towards a good resource to get this done? In my last project Ive used OkHttp, it worked pretty well, and is very easy to use: http://square.github.io/okhttp/ There are POST examples there. The only problem I had was when I needed to upload a file, for that the documentation is kinda wrong (I did got it working later). EDIT: that example is actually kinda weird, here is what worked for me (receiving a JSON as response): code:
Elias_Maluco fucked around with this message at 21:31 on Dec 14, 2015 |
# ? Dec 14, 2015 21:15 |
|
socialsecurity posted:Hey working on an Android app with Zendesk SDK integration I need to do a simple HTTP POST request with basic authentication so I can get a user token back from a ASP script I'm hosting on IIS but I cannot for the life of me get it going. Every single example I see is somehow outdated even when I try to import the libraries they are using can anyone point me towards a good resource to get this done? You're finding old examples recommending the Apache http client, right? Use okhttp as your Android http client as the above poster recommends. Apache examples are littered around the internet because its api is simple and it's built in, but don't ever use it, it's been deprecated for so long that it's finally, thankfully gone in the latest sdks.
|
# ? Dec 14, 2015 21:26 |
|
New at the IntelliJ IDEA GUI designer. Is there a good way to get the selected panel in the above image containing the three buttons to be actually centered in the window, not pushed a little bit left by the Finish button? I tried a few arrangements with the Finish button inside that panel and a horizontal spacer between it but then the Finish button wouldn't push all the way to the right edge. And also to enforce a minimum size on the whole window so it can't be shrunk smaller than needed to display those controls need -- do I have to manually figure out the number of pixels or can I do it with policies and maybe spacers? KICK BAMA KICK fucked around with this message at 00:40 on Dec 15, 2015 |
# ? Dec 15, 2015 00:36 |
|
While I dabbled a bit with Android, never had a need for making a POST request to a service. Therefore, I have a question: Doesn't the Android SDK have the java.net classes? Specifically URL, with URLConnection and such? Because, for simple stuff, you cannot really beat the builtin classes. For more complex things, yes use other libraries (Apache's or this OkHttp), but simple stuff ... why bother?
|
# ? Dec 15, 2015 00:39 |
|
KICK BAMA KICK posted:
Don't use designers for Swing. Really. They are more of a bother than help. For what you want, you can achieve that very easily with GridBagLayourManager. Here's the documentation: https://docs.oracle.com/javase/tutorial/uiswing/layout/gridbag.html Essentially, put the finish button in the panel, have a panel (spacer) in between with a weight of 1, and adjust the insets to control the margins. But anyway, I don't think this is a very intuitive design, would be better with the finish button beside the other buttons, but whatever your homework said.
|
# ? Dec 15, 2015 00:44 |
|
KICK BAMA KICK posted:
See on the left, where it says Layout Manager - GridLayoutManager ? That's what's controlling the behavior of moving things around. Try different layouts, possibly even absolute value layout, and then you can place things in different places that your current layout may just not allow. E: See what Volguus said
|
# ? Dec 15, 2015 00:46 |
|
Elias_Maluco posted:In my last project Ive used OkHttp, it worked pretty well, and is very easy to use: Awesome thank you this was right along the idea of what I was trying to accomplish I think I need some to make some slight modifications for basic auth and I will be finally making some progress on this.
|
# ? Dec 15, 2015 00:51 |
|
Thanks; I actually had started writing it out manually and then tried the designer just to see what it was like. I did like having an actual GUI to quickly tweak settings rather than sifting through the volume of code to find where the constraints were established for a particular component or whatever. I'll try going back to that and just organizing my code better this time. Not homework, just a toy I was screwing around with to learn Swing. The design made sense to me to separate the three buttons that relate to the displayed image from the Finish one that ends the current mode of operation (and to put Back and Next symmetrically offset from the center), but I don't actually know anything about UX.
|
# ? Dec 15, 2015 01:44 |
|
Volguus posted:While I dabbled a bit with Android, never had a need for making a POST request to a service. Therefore, I have a question: Depends on how simple it is. Most Android apps beyond the most hello worldy piece of junk will benefit from a proper networking library that also handles threading for you to some extent, delivers responses cleanly, and plays well with rxjava. But yeah, occasionally as a one off I'll find myself spinning up a raw httpurlconnection.
|
# ? Dec 15, 2015 01:50 |
|
socialsecurity posted:Awesome thank you this was right along the idea of what I was trying to accomplish I think I need some to make some slight modifications for basic auth and I will be finally making some progress on this. So trying this out running into a weird issue I compiled the Okio and OkHTTP libraries but it still doesn't recognize like half the commands like the .request, not sure maybe I need to import something else or what I'm missing here.
|
# ? Dec 15, 2015 02:04 |
|
socialsecurity posted:So trying this out running into a weird issue Paste the code, not the screenshot. Also, check your imports and make sure you're using the right thing.
|
# ? Dec 15, 2015 02:09 |
|
Volmarias posted:Paste the code, not the screenshot. Also, check your imports and make sure you're using the right thing. compile 'com.squareup.okhttp:okhttp:2.7.0' compile 'com.squareup.okio:okio:1.6.0' Importing from the mainactivity, import com.squareup.okhttp.MediaType; import com.squareup.okhttp.OkHttpClient; import com.squareup.okhttp.Request; import com.squareup.okhttp.RequestBody; import com.squareup.okhttp.Response; import com.squareup.okhttp.Credentials; import com.squareup.okhttp.FormEncodingBuilder; Code code:
|
# ? Dec 15, 2015 02:20 |
|
Hey java thread, I need your help with simple java stuff I can't seem to wrap my head around how to add an object to an arrayList. The arraylist and object are both in different classes, I've exhausted and read a bunch of different sources and can't seem to find any help. Here's the code for the Person class which creates the object code:
code:
Also here's the main program: code:
|
# ? Dec 19, 2015 15:08 |
|
casual poster posted:Hey java thread, I need your help with simple java stuff The diamond brackets after the ArrayList specify what sort of objects go into it. Check your code and think about what you're going to put into your ArrayList.
|
# ? Dec 19, 2015 15:28 |
|
Your problem lies in the following two lines:code:
code:
I'd also rename the list from 'person' to 'phonebook' or whatever for clarity, so the line would become: code:
You would do that by writing code:
|
# ? Dec 19, 2015 15:34 |
|
Holy crap it worked! Thanks a lot you two!
|
# ? Dec 19, 2015 16:38 |
|
casual poster posted:Holy crap it worked! Thanks a lot you two!
|
# ? Dec 19, 2015 17:42 |
|
casual poster posted:Holy crap it worked! Thanks a lot you two! Go back and read the error the message the compiler was giving your before and see if it makes sense to you now.
|
# ? Dec 21, 2015 18:16 |
|
What's the current recommendation for REST API frameworks? I'm working on something for a personal project and I'm not sure what to use. I started down the path of using Jersey with Tomcat but I'm not sure if that's the best approach. I'm thinking of looking into spring-boot but the Spring framework kind of scare me. Edit: Even though it's for a personal project I'd to use it to learn something that would be useful for working on a larger application as well. Also, I've looked at Spark (not Apache Spark) but I'm not sure how mature that is. Ochowie fucked around with this message at 01:17 on Dec 28, 2015 |
# ? Dec 28, 2015 01:02 |
|
Ochowie posted:What's the current recommendation for REST API frameworks? I'm working on something for a personal project and I'm not sure what to use. I started down the path of using Jersey with Tomcat but I'm not sure if that's the best approach. I'm thinking of looking into spring-boot but the Spring framework kind of scare me. Jersey is fine. Spring isn't as scarey as it first seems.
|
# ? Dec 28, 2015 01:19 |
|
Ochowie posted:What's the current recommendation for REST API frameworks? I'm working on something for a personal project and I'm not sure what to use. I started down the path of using Jersey with Tomcat but I'm not sure if that's the best approach. I'm thinking of looking into spring-boot but the Spring framework kind of scare me. Jersey is good - I've used it professionally at two companies that were exclusively REST microservices. Spring is fine - I used it at my last job - but imo it is a bit obnoxious to work with, since it tries to be everything for everyone. At my current place, we use HK2 for dependency injection, and just pass a JSON file to the app at startup with all the configuration that we need. We use GSON to deserialize it into a POJO, and use the HK2 AbstractBinder to register all of the objects/values that we'll need before we start the Jersey server.
|
# ? Dec 28, 2015 02:06 |
|
Ochowie posted:What's the current recommendation for REST API frameworks? I'm working on something for a personal project and I'm not sure what to use. I started down the path of using Jersey with Tomcat but I'm not sure if that's the best approach. I'm thinking of looking into spring-boot but the Spring framework kind of scare me. Jersey is great because its JAX-RS, so if for some reason you have an issue you can swap in another JAX-RS implementation and everything is pretty much the same. But Jersey is the reference implementation so its what seems to get the most active development. Spring feels like such a major framework, you don't want to use it unless you're using Spring for everything. It isn't "just" a REST library, its a full on framework. Its good but its very much its own thing. E:FB
|
# ? Dec 28, 2015 02:10 |
|
Zaphod42 posted:Jersey is great because its JAX-RS, so if for some reason you have an issue you can swap in another JAX-RS implementation and everything is pretty much the same. But Jersey is the reference implementation so its what seems to get the most active development. JAX-RS is great, until you need something that's not in the specification. Then you go full-Jersey on it. Then you need something that even Jersey cannot handle on its own. Then you go 3rd-party library on it. Or you can go Spring from the beginning and don't worry about that poo poo. Spring can be as big or as small as you want it, but it usually integrates pretty well with a lot of libraries and with a lot of projects under the Spring umbrella. It is scary if you want to get/understand everything at once, is pretty mild if you take it slow, just chew the pieces you know you can swallow.
|
# ? Dec 28, 2015 04:34 |
|
Volguus posted:JAX-RS is great, until you need something that's not in the specification. Then you go full-Jersey on it. Then you need something that even Jersey cannot handle on its own. Then you go 3rd-party library on it. What's the best way to get into Spring? I've been reading a little bit about Spring Boot as a way to get everything wired up and running. Is this a good place to start?
|
# ? Dec 28, 2015 05:25 |
|
Yeah, just follow a guide like this one and then afterwards just add any additional features you need.
|
# ? Dec 28, 2015 14:37 |
|
Ochowie posted:What's the best way to get into Spring? I've been reading a little bit about Spring Boot as a way to get everything wired up and running. Is this a good place to start? Treat it a little like magic. Assume that it does anything you need it to do out of the box with minimal effort, you just need to find (google) the right magic words, such as SimpleBeanFactoryAwareAspectInstanceFactory (http://docs.spring.io/spring-framework/docs/2.0.8/api/org/springframework/aop/config/SimpleBeanFactoryAwareAspectInstanceFactory.html). After a few months, you might start digging around and seeing how it fits together under the hood, but it's usually not required.
|
# ? Dec 28, 2015 17:11 |
|
baquerd posted:Treat it a little like magic. Assume that it does anything you need it to do out of the box with minimal effort, you just need to find (google) the right magic words, such as SimpleBeanFactoryAwareAspectInstanceFactory. Which leads to stuff like this, which highlights the near-impossibility of distinguishing actual Spring magic from random words smooshed together.
|
# ? Dec 29, 2015 03:42 |
|
Not in the same space as the frameworks the others are mentioning, but I've worked on smaller projects and microservices with vert.x and it's super fun. http://vertx.io/ Just java - good Java, rxjava, no @InjectBaseReflectiveMagicBeanFactoryImplStrategySingleton to contend with. Not saying those things are bad. But sometimes you just want to write Java code that does something remotely similar to what it looks like it does. speng31b fucked around with this message at 04:59 on Dec 29, 2015 |
# ? Dec 29, 2015 04:39 |
|
Haha, you guys sound like little kids that can't understand the math homework and therefore math is stupid. Is there SimpleBeanFactoryAwareAspectInstanceFactory in spring? Yes. Do you need to know it exists? Most likely not. I've been working with spring for 8 years now, I wrote aspects of every kind imaginable, yet I've never once saw SimpleBeanFactoryAwareAspectInstanceFactory. Are there classes named like in the http://java.metagno.me/ site? Yes they are. Will you need them? Dunno, most likely not, depends. I kinda understood the old days fear of the dreaded XML configuration hell, but now you have everything you want via annotations, you just tell it (in plain motherfucking english) what you want and it does it for you. Treat it like magic? Sure, you can I guess, though it doesn't hurt (after you get used to it) to actually understand how it's doing what it's doing. Now you have Spring Boot, which, even easier than before you can bootstrap a simple app in minutes. Is JAX-RS better? It depends on the taste. Yes it looks OK. If you live within its constraints, is wonderful. You want more? You're hosed and just say gently caress it with the standards and go in the 3rd party libraries. Want pretty Jersey class names? Does ContainerMessageBodyWorkersInitializer look ok? How about AbstractContainerLifecycleListener? They're there, may not need to see them/use them ever, but they're there. Instead of just looking up class names in the javadoc, how about use it for 5 minutes : https://spring.io/guides/gs/spring-boot/ and then make up your mind. Otherwise, you really just sound like little kids angry at the toy they don't have. Can't really explain why you're angry (never played with it), but it surely pisses you off that it has a red hat while obviously blue would have been a better choice.
|
# ? Dec 29, 2015 08:59 |
|
We're making fun of the words because they're long and funny, which is easy to do with Spring. I don't see anyone recommending to not use Spring because of that, so calm right on down. Did your parents name you BeanFactoryImpl and it's a sore spot? It's a family name? Note I specifically said Spring isn't bad, and qualified that the framework I suggested is probably suited to smaller projects and microservices.
speng31b fucked around with this message at 15:25 on Dec 29, 2015 |
# ? Dec 29, 2015 15:21 |
On the subject of Spring, what's the status and relation between JPA and Hibernate for persistence? The spring.io guide page is oddly devoid of Hibernate mentions. Does JPA supplant Hibernate? EDIT: http://stackoverflow.com/questions/9881611/whats-the-difference-between-jpa-and-hibernate Jo fucked around with this message at 03:14 on Jan 4, 2016 |
|
# ? Jan 4, 2016 02:01 |
|
Jo posted:On the subject of Spring, what's the status and relation between JPA and Hibernate for persistence? The spring.io guide page is oddly devoid of Hibernate mentions. Does JPA supplant Hibernate? Theoretically you could replace Hibernate with another JPA implementation and your project would continue to function without any code change. In practice you probably can't.
|
# ? Jan 4, 2016 03:14 |
|
Sedro posted:JPA is a specification (JSR). Hibernate is the most widely used implementation of the spec. Spring is an unrelated project. Moving to another implementation is a lot easier then it was during the past. The biggest issue I ran into was were we used a few nice functions that Hibernate supported but Eclipselink did not support.
|
# ? Jan 4, 2016 04:02 |
|
Sedro posted:Theoretically you could replace Hibernate with another JPA implementation and your project would continue to function without any code change. In practice you probably can't. Hibernate has some (now deprecated) annotations that also exist in JPA, so you may have to change some imports. These are largely compatible, as far as I remember.
|
# ? Jan 4, 2016 09:17 |
|
I was toying around with Spring Boot and Webjars a little bit and building/minifying my assets using WRO and it works pretty well: In debug I read my source files from disk, in production I get minified assets from the classpath. However, it lacks more modern processors like a JSX compiler or ES6 transpiler (e.g. BabelJS). I'd really like to avoid setting up a terribly fragile Node-based build pipeline based on Gulp or whatever, so I was wondering what you guys are using?
|
# ? Jan 4, 2016 10:08 |
|
You can run some of the tooling with Nashorn if you have limited requirements, but yeah, were using a Node and gulp using frontend-maven-plugin. It's actually not very fragile if you use npm shrinkwrap or manage the dependencies yourself, but definitely not ideal.
|
# ? Jan 4, 2016 12:55 |
|
I'm going crazy and I've managed to boil my example code down as far as this:Java code:
|
# ? Jan 4, 2016 18:50 |
|
You want B's constructor to set your string, rather than declaring an entirely new variable. I'm actually not quite sure how that's compiling, since you're declaring a member variable that already exists. Check for typos, and are you SURE this example reflects your code?
|
# ? Jan 4, 2016 18:57 |
|
|
# ? Jun 12, 2024 21:08 |
|
Child classes are allowed to "hide" members from their parent classes. It gets annoying, like in this case. Eclipse, at least, can be configured to warn when a member variable or method parameter is hiding another variable.
|
# ? Jan 4, 2016 19:05 |