Search Results

Search found 18 results on 1 pages for 'jboyd'.

Page 1/1 | 1 

  • Add Hexidecimal Header Info to JPEG File Using Java

    - by jboyd
    I need to add header info to a JPEG file in order to get it to work properly when shared on some websites, I've tracked down the correct info through a lot of Hex digging, but now I'm kind of stuck trying to get it into the file. I know where in the file it needs to go, and I know how long it is, my problem is that RandomAccessFile just overwrites existing data in the file and FileOutputStream appends the data to the end. I don't want either, I want to INSERT data starting at the third byte. My example code: File fileToChange = new File("someimage.jpg"); byte[] i = new byte[2]; i[0] = (byte)Integer.decode("0xcc"); i[1] = (byte)Integer.decode("0xcc"); RandomAccessFile f = new RandomAccessFile(new File("videothing.jpg"), "rw"); long aPositionWhereIWantToGo = 2; f.seek(aPositionWhereIWantToGo); // this basically reads n bytes in the file f.write((byte[])i); f.close(); So this doesn't work because it overwrites, and does not insert, I can't find any way to just insert data into a file

    Read the article

  • Spring MVC Best Practice Handling Unrecoverable Exceptions In Controller

    - by jboyd
    When you have a controller that does logic with services and DAO's that may throw an unrecoverable exception, what is the best practice in dealing with those method calls? Currently an app I'm working on has very lengthy try catch methods that simply err.out exception messages, this doesn't seem very robust and I think that this code smells, is there any cookie cutter best practice for handling this in spring-mvc?

    Read the article

  • Spring 3 Annotations

    - by jboyd
    I can't get spring annotations to work at all, I'm just trying to get the simplest thing to work... .../mycontext/something - invokes method: @RequestMapping(value = "/something") @ResponseBody public String helloWorld() { System.out.println("hello world"); return "Hello World"; } My main problem is no matter how hard I try, I can't find a complete SIMPLE example of the configuration files needed, every spring tutorial is filled with junk, I just one one controller to handle a request with a mapping and can't get it to work does anyone know of a simple and complete spring example. pet-clinic is no good, it's way too complicated, I have a tiny basic use case and it's proving to be a real pain to get working (this always happens with Spring)

    Read the article

  • Interface Design Problem: Storing Result of Transactions

    - by jboyd
    Requirements: multiple sources of input (social media content) into a system multiple destinations of output (social media api's) sources and destinations WILL be added some pseudo: IContentProvider contentProvider = context.getBean("contentProvider"); List<Content> toPost = contentProvider.getContent(); for (Content c : toPost) { SocialMediaPresence smPresence = socialMediaService.getSMPresenceBySomeId(c.getDestId()); smPresence.hasTwitter(); smPresence.hasFacebook(); //just to show what this is smPresence.postContent(c); //post content could fail for some SM platforms, but shoulnd't be lost forever } So now I run out of steam, I need to know what content has been successfully posted, and if it hasn't gone too all platforms, or if another platform were added in the future that content needs to go out for it as well (therefore my content provider will need to not only know if content has gone out, but for what platforms). I'm not looking for code, although sample/pseudo is fine... I'm looking for an approach to this problem that I can implement

    Read the article

  • stopping backspace on multiple browsers using jQuery

    - by jboyd
    I am attempting to stop a backspace keydown event from being handled by browsers, I'm using the jquery library, so I need to get the original event, but on some browsers (firefox at least) I get an error when trying to set the original events keyCode = 0, it gives and error saying that only a getter exists for that property. function blockBackspace(event) { var altKey = event.originalEvent.altKey; var srcElementType = event.originalEvent.srcElement; if( (altKey) || ((event.keyCode == 8) && (srcElementType != "text" && srcElementType != "textarea" && srcElementType != "password")) || ((event.ctrlKey) && ((event.keyCode == 78) || (event.keyCode == 82)) ) || (event.keyCode == 116) ) { event.keyCode = 0; event.returnValue = false; event.originalEvent.keyCode = 0; event.originalEvent.returnValue = false; //sets process backspaceFlag to keep multiple handlers from removing text processBackspace = true; } } so I'm not exactly sure what to do next, every solution I find yields more problems. There must be ways around this problem or else other text areas (that's kind of what I'm building) would not work

    Read the article

  • Injecting Annotated Bean into Regular Bean

    - by jboyd
    AppContext.xml <bean id="myBean" class="com.myapp.MyClass"> <property ref="myService"/> </bean> MyService.java @Service public class MyService { ... } This will throw an exception stating that no bean can be found for property "myService", which I understand because it can't be found in the context files, but I can autowire that field in other spring managed beans, but I need to explicitly build the bean in my context because the POJO is not editable in the scope of my project.

    Read the article

  • Using a Session Scoped Bean

    - by jboyd
    The following code is returning null: private MyAppUser getMyAppUser(HttpSession session) { MyAppUser myAppUser = (MyAppUser) session.getAttribute("myAppUserManager"); return myAppUser; } Despite the fact that I have the following in my context: <bean id="myAppUserManager" class="com.myapp.profile.MyAppUser" scope="session"/> This doesn't make any sense to me, the "myAppUser" bean is a bean that absolutely can never be null, and I need to be able to reference it from controllers, I don't need it in services or repositories, just controllers, but it doesn't seem to be getting stored in the session, the use case is extremely simple, but I haven't been able to get to the bottom of what's wrong, or come up with a good workaround

    Read the article

  • Spring MVC working with Web Designers

    - by jboyd
    When working with web-designers in a Spring-MVC and JSP environment, are there any tools or helpful patterns to reduce the pain of going back and forth from HTML to JSP and back? Project requirements dictate that views will change often, and it can be difficult to make changes efficiently because of the amount of Java code that leaks into the view layer. Ideally I'd like to remove almost all Java code from the view, but it does not seem like this works with the Spring/JSP philosophy where often the way to remove Java code is to replace that code with tag libraries, which will still have a similar problem. To provide a little clarity to my question I'm going to include some existing code (inherited by me) to show the kinds of problems I'm likely to face when change the look of our views: <%-- Begin looping through results --%> <% List memberList = memberSearchResults.getResults(); for(int i = start - 1; i < memberList.size() && i < end; i++) { Profile profile = (Profile)memberList.get(i); long profileId = profile.getProfileId(); String nickname = profile.getNickname(); String description = profile.getDescription(); Image image = profile.getAvatarImage(); String avatarImageSrc = null; int avatarImageWidthNum = 0; int avatarImageHeightNum = 0; if(null != image) { avatarImageSrc = image.getSrc(); avatarImageWidthNum = image.getWidth(); avatarImageHeightNum = image.getHeight(); } String bgColor = i % 2 == 1 ? "background-color:#FFF" : ""; %> <div style="float:left;clear:both;padding:5px 0 5px 5px;cursor:pointer;<%= bgColor %>" onclick='window.location="profile.sp?profileId=<%= profileId %>"'> <div style="float:right;clear:right;padding-left:10px;width:515px;font-size:10px;color:#7e7e7e"> <h6><%= nickname %></h6> <%= description %> </div> <img style="float:left;clear:left;" alt="Avatar Image" src="<%= null != avatarImageSrc && avatarImageSrc.trim().length() > 0 ? avatarImageSrc : "images/defaultUserImage.png" %>" <%= avatarImageWidthNum < avatarImageHeightNum ? "height='59'" : "width='92'" %> /> </div> <% } // End loop %> Now, ignoring some of the code smells there, it's obvious that if someone wants to change the look of that DIV it would be neccesary to re-place all the Java/JSP code into the new HTML given (the designers don't work in JSP files, they have their own HTML versions of the website). Which is tedious, and prone to errors.

    Read the article

  • Serving Advertisements - What should the View be responsible for?

    - by jboyd
    My requirements are that Ads have a definite size, could be different media types (although I'd like to focus on Images first) and need to have their impressions tracked I'm using Spring-MVC and will likely have a service that will retrieve all the relevant ad information adService.getAdsForPage("news"); adService.getFeaturedAd("news"); and so on... My question is, what will my view be responsible for? I need to track impressions, and I can only really think of how to do that on the server side. But what would my view look like. I'd like any example code, ideas, or a link to a page that has some in depth discussion of this topic

    Read the article

  • Deploying Multiple Environments in Spring-MVC

    - by jboyd
    Currently all web apps are deployed using seperate config files: <!-- <import bean.... production/> --> <import bean... development/> This has disadvantages, even if you only need to swap out one config file, that I'm sure everyone is familiar with (wondering what just deployed without searching through XML is one of them) I want to add Logging to my application that basically says 'RUNNING IN PRODUCTION MODE', with a description of the services deployed and what mode they are working in. RUNNING IN PRODUCTION MODE Client Service - Production Messaging Service - Local and so on... Is this possible in Spring using a conventional deployment (putting a war on a server)? What other things do people do to manage deployments and software configurations? If not, what other ways could you achieve something similar?

    Read the article

  • Java/Groovy File IO Replacing an Image File with it's own Contents - Why Does This Work?

    - by jboyd
    I have some JPG files that need to be replaced at runtime with a JFIF standardized version of themselves (we are using a vendor that gives us JPG that do not have proper headers so they don't work in certain applications)... I am able to create a new file from the existing image, then get a buffered image from that file and write the contents right back into the file without having to delete it and it works... imageSrcFolder.eachFileMatch ( ~/.*\.jpg/, { BufferedImage bi = ImageIO.read( it ) ImageIO.write( bi, "jpg", it ) }); The question I have is why? Why doesn't the file end up doubled in size? Why don't I have to delete it first? Why am I able to take a file object to an existing file and then treat it as if it were a brand new one? It seems that what I consider to be a "file" is not what the File object in java actually is, or else this wouldn't work at all. My code does exactly what I want it to do, but I'm not convinced it always will... it just seems way too easy

    Read the article

  • Spring MVC - JSP - Place to Store Environment Specific Constants

    - by jboyd
    Where in the Spring-MVC/JSP application would you store things that need to be accessed by both the controllers and views such as environment specific base_url's, application ids to be used in javascript and so on? I've tried creating an application scoped bean and then at the top of my JSPs, but that doesn't seem to be working. <!-- Environment --> <bean id="myEnv" class="com.myapp.MyAppEnvironment" scope="application"> <property name="baseUrl" value="http://localhost:8080/myapp/"/> <property name="videoPlayerId" value="234346565"/> </bean> And using it in the following manner <jsp:useBean id="myEnv" scope="application" type="com.myapp.MyAppEnvironment"/>

    Read the article

  • A better way to do XML in Java

    - by jboyd
    There are a lot of questions that ask the best XML parser, I am more interested in what is the XML parser that is the most like Groovy for Java? I want: SomeApiDefinedObject o = parseXml( xml ); for( SomeApiDefinedObject it : o.getChildren() ) { System.out.println( it.getAttributes() ); } The most important things are that I don't want to create an object for every type of filed, I'd rather just deal with them all as strings, and that building the XML doesn't require any converters or anything, just a simple object that is already defined If you have used the Groovy XML parser, you will know what I'm talking about Alternatively, would it be better for me to just use Groovy from Java?

    Read the article

  • Social Media Java Design Problem

    - by jboyd
    I need to put something together quickly that will take blog posts and place them on social media sites, the requirements are as follows: Blog Entries are independent records that already exist, they have a published date and a modified date, the blog entry application cannot be changed, at least not substantially A new blog entry, or update needs to be sent to social media sites I currently do not need to update or delete social media communications if the blog entry is edited, or deleted, though I may need to later My design problems here are as follows: how do I know the status of each update how can I figure out what blog entry updates and postings have already been sent out? how can I quickly poll the blog entry table for postings that haven't yet been sent out? Avoiding looking at each Entry record from the DB as an object and asking if it's been sent already. That would be too slow. I cannot hook into any Blog Entry update code, my only option would be to create a trigger that an update queues something to be processed I'm looking for general guiding principles here, the biggest problem I'm having is coming up with any reasonable way to figure out if a blog entry should be sent to our social media sites in the first place

    Read the article

  • Spring 3 MVC - Form Failure Causes Exception When Reloading JSP

    - by jboyd
    Using Spring 3 MVC, please bear with the long code example, it's quite simple, but I want to make sure all relevant information is posted. Basically here is the use case: There is a registration page, a user can login, OR fill out a registration form. The login form is a simple HTML form, the registration form is a more complicated, Spring bound form that uses a RegistrationFormData bean. Here is the relevant code: UserController.java ... @RequestMapping(value = "/login", method = RequestMethod.GET) public String login(Model model) { model.addAttribute("registrationInfo", new ProfileAdminFormData()); return "login"; } ... @RequestMapping(value = "/login.do", method = RequestMethod.POST) public String doLogin( @RequestParam(value = "userName") String userName, @RequestParam(value = "password") String password, Model model) { logger.info("login.do : userName=" + userName + ", password=" + password); try { getUser().login(userName, password); } catch (UserNotFoundException ex) { logger.error(ex); model.addAttribute("loginError", ex.getWebViewableErrorMessage()); return "login"; } return "redirect:/"; } ... @RequestMapping(value = "/register.do") public String register( @ModelAttribute(value = "registrationInfo") ProfileAdminFormData profileAdminFormData, BindingResult result, Model model) { //todo: redirect if (new RegistrationValidator(profileAdminFormData, result).validate()) { try { User().register(profileAdminFormData); return "index"; } catch (UserException ex) { logger.error(ex); model.addAttribute("registrationErrorMessage", ex.getWebViewableErrorMessage()); return "login"; } } return "login"; } and the JSP: ... <form:form commandName="registrationInfo" action="register.do"> ... So the problem here is that when login fails I get an exception because there is no bean "registrationInfo" in the model attributes. What I need is that regardless of the path through this controller that the "registrationInfo" bean is not null, that way if login fails, as opposed to registration, that bean is still in the model. As you can see I create the registrationInfo object explicitly in my controller in the method bound to "/login", which is what I thought was going to be kind of a setup method" Something doesn't feel right about the "/login" method which sets up the page, but I needed to that in order to get the page to render at all without throwing an exception because there is no "registrationInfo" model attribute, as needed by the form in the JSP

    Read the article

  • Spring 3 MVC - Does Anything Just Work? Very Simple Use Case Not Working

    - by jboyd
    index.jsp ... <h1> ${myobject} </h1> ... HomeController.java @RequestMapping(value = "/index") public ModelAndView indexPath() { System.out.println("going home"); return new ModelAndView("index", "myobject", "isastring"); } Output: going home The <h1> on index doesn't show anything, how is this even possible? I absolutely cannot get my index.jsp to show this bean, I've tried using a usebean, I've tried storing it on the session, and now I'm directly placing it in the model. Nothing works. Spring 3 has been like every other spring release, intensely frustrating.

    Read the article

  • JSP Component Creation

    - by jboyd
    When creating JSP pages one thing that I'd often like is the ability to do something like this: <jsp:include page="fancystoryrenderer.jsp" value="${aStoryObjectInMyModel}/> ... fancystoryrenderer.jsp <div id="fancymainbody"> ... ${theStory.title} ... </div> The main important characteristics of this is that I can reuse the same component on the same JSP page in different places without having to copy paste the component and give the story variables different names, notice that the story is called "theStory" in the JSP and not "aStoryObjectInMyModel", the linkage between our model has been broken by the view, which is a good thing in this case How do you do this?

    Read the article

1