Skip to main content

Posts

Showing posts from February 15, 2012

Change value JS, PHP getting old value

I've a silly problem. Depending on a the visibility of a div I want to set a hidden value if($('#crewMember').is(':visible')) { $('#visibility').attr('value', 'hidden') } else { $('#visibility').attr('value', 'visible') } This works. I've checked it via FireBug and I can see that the HTML has changed. But when I try to get this value after form submission I get the original value, not the changed value. echo $_POST['visibility'] //returns default value, not the adjusted valueHow come? How come? EDIT SOme example code <html> <script type="text/javascript"> $(document).ready(function() { $('#div').click(function() { $('#visibility').val('hidden'); $('#value').html('hidden value: ' + $('#visibility').val()); }); $('#value').html('hidden value: ' + $('#visibility').va

change the url in facebook comments code?

on my website I have more than 200 pages and I want to add facebook comments feature to my website. I ran to this problem is that I have to change the code (the url) for each page. I do not want to change the code for every page. If you can see the second piece of code contain Url goes here can I include a method like location.href so that it can use the current url of the page. can I do this ? I do not care if it is php, javascript, or anything ealse. Include the JavaScript SDK on your page once, ideally right after the opening <body> tag. <div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=324524777119"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script> Place the code for your plugin

PHP passing variable in __construct of a class

ive browsed many articles here but I just can't make this work for the life of me. class Database{ private $host; function __construct( $vhost = ''){ $this->host = $vhost == '' ? db_host : $vhost; } function connect(){ echo "Host: ".$this->host; } } I've omitted some unnecessary code but it's same concept. I get "Fatal error: Using $this when not in object context" when trying to echo. What am I missing here?

Including a file in json_encode()

Thsi does not seem to work: $msg="Your changes have been saved successfully"; $view=include('application/view/admin/cms/_slides-current.php'); $return_array=array('success'=>true, 'msg'=>$msg, 'view'=>$view); echo json_encode($return_array); The array needs to be passed back to a jQuery ajax success callback. Anybody know how it should be done? The include file is simply a HTML template. This HTML template will be inserted on to the page. Is there any way other than using json_encode() to do what I am trying to do? success: function(result){ alert(result.msg); if(result.success == true) { $('#slides').html(result.view); } }

How to read an SVG with a given size using PHP Imagick?

I have the following code: $image = new Imagick(); $image->setBackgroundColor(new ImagickPixel('green')); $image->setSize(20,20); $image->readImageBlob(file_get_contents('./some/path/image.svg')); It loads the SVG just fine but the setSize just gets completely ignored. It renders at 550x100, as per it's definition: <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="550px" height="100px" viewBox="0 0 550 100" enable-background="new 0 0 550 100" xml:space="preserve"> Has anyone got experience in getting SVG files to play nice with setSize ?

getting the image width from the href tag instead from img tag

i am working on a project in which i require the width of a image from href when i click on the specific image the width if the image displays in a alert . the following is the href and image code i am using <li> <a href="<?php echo $pic;?>?id=<?php echo $id;?>&pic=<?php echo $picID;?>" data-title="" data-desc=" " data-rel="group2" data-bw="<?php echo $pic;?>" class="lightbox" id="plzx" > <img src="<?php echo $pic;?>" width="160" height="160" title="Click To View"/></a> </li> whenever i try to get the width of the image it takes the image width from the img tag not from the href . as the img tag width is already defined "160" . is there a way possible for getting the width of the image from the <a href i am using the following code which is nit working $(

Escaping quotes - moving from PHP4 to PHP5

I've inherited a php4 site that needs to run on my PHP5 Server, I've solved most of the issues but can't figure out what the author was trying to do here. Well, to be precise, he was tring to quote the submitted text but I'm not sure how this function is supposed to work and how I should do it in PHP5? # Function to safely add slashes when magic quotes is switched off function safe_slash($string) { if (!get_magic_quotes_gpc()) { $string = addslashes($string); } return $string; }

How can i store the values of array_count_values in array of object?

i have array like below which is sorted by array_count_values function, Array ( [Session #1: Tues May 31st - Fri June 10th (1-5:30PM)#1 only: 1pmADV] => 3 [Session #2: Tues June 14th - Fri June 24th (9-2:00PM)#1 only: 2pmADV] => 2 [Session #4: Tues July 12th - Fri July 22nd (9-2:00PM)#1 only: 1:30pmADV] => 2 ) i need to convert this array into array of object like below, stdClass Object ( [Itemname] => Session #1: Tues May 31st - Fri June 10th (1-5:30PM)#1 only: 1pmADV [Quantity] => 3 ) stdClass Object ( [Itemname] => Session #2: Tues June 14th - Fri June 24th (9-2:00PM)#1 only: 2pmADV [Quantity] => 2 ) stdClass Object ( [Itemname] => Session #4: Tues July 12th - Fri July 22nd (9-2:00PM)#1 only: 1:30pmADV [Quantity] => 2 ) how can i do this?

app application request popup filter users

Is it possible to invite only girls to my app in FB.ui popup ? thank You for any suggestions, if not tneh maybe there is any other solution available ? User is in the app. There is invite friends button with jscode: $('#btnInvite').bind("click", function(){ FB.ui({method:'apprequests',title:'test',message:'test',data:'test'}); }) And then popup with friends appears to be selected. Is it possible to filter this list only to female users (app is dedicated for girls)

How to manipulate a rowset data from sql to php

I have asked a question about how to retrieve data from different tables in sql How to get data from 4 tables in 1 sql query? When I run the query for my sample data I get 3 rows, anyway being many-to-many relationship between courses and categories I will always get more rows for same course. My question is how do I handle this data in PHP? I get an array and what I want would be something like: Array ( [0] => stdClass Object ( [name] => course name [tutor] => tutor name [categories] => Array ( categories here ) ); Should I just fetch the data from the categories in a foreach loop after I fetch a course? That would mean bad performance for large amount of data.

PHP query does not return result

This query is not returning any result as there seems to be an issue with the sql. $sql = "select region_description from $DB_Table where region_id='".$region_id."' and region_status =(1)"; $res = mysql_query($sql,$con) or die(mysql_error()); $result = "( "; $row = mysql_fetch_array($res); $result .= "\"" . $row["region_description"] . "\""; while($row = mysql_fetch_array($res)) { echo "<br /> In!"; $result .= " , \"" . $row["region_description"] . "\""; } $result .= " )"; mysql_close($con); if ($result) { return $result; } else { return 0; } region_id is passed as 1. I do have a record in the DB that fits the query criteria but no rows are returned when executed. I beleive the issue is in this part , region_id='".$region_id."' so on using the gettype function in my php it turns out that the datatype of reg

special character like " not showing properly in pdf

I using html2fpdf library to generate a pdf in codeigniter .I have some data in a varchar field like " What are your child’s academic strengths? " which is showing like " What are your child’s academic strengths? " . How I can show it as it is in the database .(I have tried htmlspecialchars_decode , html_entity_decode function but it not worked. )

creating my own library in symfony 2

I'm trying to create my own library in a Symfony2 project but I'm having a hard time doing so... Basically I want to reuse an FTP browser class I made for another project. I copied the class into /vendor/mylib and tried to autoload it like that $loader->registerPrefixes(array( 'Twig_Extensions_' => __DIR__.'/../vendor/twig-extensions/lib', 'Twig_' => __DIR__.'/../vendor/twig/lib', 'Mylib_' => __DIR__.'/../vendor/mylib' )); I then tried to instantiate a Mylib_Test object inside my bundle's controller and I got this error : Fatal error: Class 'Test\FrontBundle\Controller\Mylib_Test' not found in /Applications/MAMP/htdocs/sf2_project/src/Test/FrontBundle/Controller/WelcomeController.php on line 26 Anyone has an idea on how to do this ?

How do I make a GUI that looks like the attached picture of a simple stock market app?

Using these layouts; FlowLayout, BoxLayout, GridLayout, BorderLayout and GridBagLayout im trying to make my GUI look like below. I tried Flow, Grid and Border but I couldn't make it look the same.

About the BLOB datatype in MySQL

I have stored an image in MySQL using the BLOB datatype. I am able to retrieve image through JSP but when I use Chrome or Firefox browser I am unable to view the image. It is displaying in an encrypted format. Can anyone please help me?

Delphi DEC library (Rijndael) encryption

I am trying to use the DEC 3.0 library ( Delphi Encryption Compedium Part I ) to encrypt data in Delphi 7 and send it to a PHP script through POST, where I am decrypting it with mcrypt (RIJNDAEL_256, ECB mode). Delphi part: uses Windows, DECUtil, Cipher, Cipher1; function EncryptMsgData(MsgData, Key: string): string; var RCipher: TCipher_Rijndael; begin RCipher:= TCipher_Rijndael.Create(KeyStr, nil); RCipher.Mode:= cmECB; Result:= RCipher.CodeString(MsgData, paEncode, fmtMIME64); RCipher.Free; end; PHP part: function decryptMsgContent($msgContent, $sKey) { return mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $sKey, base64_decode($msgContent), MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND)); } The problem is that the decryption from PHP doesn't work and the output is gibberish, differing from the actual data. Of course, Delphi Key and PHP $Key is the same 24 characters string. Now I know DEC 3.0 is old and

codeigniter non latin characters ajax call

I have a textarea and a button where i send the text via ajax to the database to post it. However when i post non-latin characters... it wont get them and it returns blank... if the text is in latin characters it works fine... my js code $.ajax({ type: "POST", url: www+"controller/postText", dataType: 'json', data: { input : input.val(), }, success: function(data) { return data; } }); my php code public function postText(){ $input = isset($_POST["input"]) ? trim($_POST["input"]) : ""; echo $input; return false; }

Remove the parent array key in PHP?

I have an array structure like this : Array ( [donate] => Array ( [amount_other] => 222 [pay_method] => Array ( [5] => Array ( [first_name] => sam [last_name] => indi [cc_type] => mc [cc_number] => 5123456789012346 [cc_ccv2] => 111 [cc_exp_month] => 10 [cc_exp_year] => 20 ) ) [notes] => Test comment. ) ) I want to remove key [5] from the array, so that the new array becomes : Array ( [donate] => Array ( [amount_other] => 222 [pay_method] => Array ( [first_name] => sam [last_name] => indi [cc_type] => mc [cc_number] => 5123456789012346

Agent"s behaviour in Multi-agent systems?

I have request agent and several resource agents in my project. I created a agent application and when I run this application every time I got one result. thats mean I call methods step by step without going accessing these behaviours in random order. How can I implement this random behaviour in jade without using random? Because my supervisor does not like to use Random in Agent behaviour.

JTextPane wrap long words

For some reason JTextPane only warp text if there are spaces between words, consider the following example: package textpane; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTextPane; public class TextPaneLongLine { public static void main(String[] args) { final JFrame frame = new JFrame("TextPane"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(200, 200); JTextPane textPane = new JTextPane(); JScrollPane scollPane = new JScrollPane(textPane); scollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); frame.add(scollPane); frame.setVisible(true); } } As you can see, if a long line without spaces is typed it will go of the view area. But if the line have spaces JTextPane will automatic split the line to fit the view area. Replacing the JTextPane with JEditorPane will work as

Maven looking for wrong archetype packaging

I successfully created an archetype. The archetype is referenced in my company's Nexus, the catalog looks well formed. But when I try to generate a project from this archetype, maven will look for a jar, and my archetype is packaged as a 'maven-archetype' (see the stack trace below) [INFO] [archetype:generate {execution: default-cli}] [INFO] Generating project in Interactive mode [INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0) Choose archetype: 1: local -> com.XXX.archetypes:frameworkV4Project Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): : 1 Downloading: http://XXX/content/repositories/xxx-releases/com/xxx/archetypes/frameworkV4Project/1.0.0/frameworkV4Project-1.0.0.jar [INFO] Unable to find resource 'com.XXX.archetypes:frameworkV4Project:jar:1.0.0' in repository frameworkV4Project-repo (http://XXX/content/repositories/XXX-releases) Downloadi

How to make simplest servlet filter respect setted character encoding

Gentlemen, it feels like I'm stuck. I'm trying to write the simplest servlet Filter (and deploy it to tomcat). It's a groovy code, but actually I'm heavily usin java approaches here, so it is almost copypaste, that's the reason I've added java tag as well. My question is - how can I insert UTF-8 string to filter? Here is the code: `public class SimpleFilter implements javax.servlet.Filter { ... public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws java.io.IOException, javax.servlet.ServletException { PrintWriter out = response.getWriter() chain.doFilter(request, wrapResponse((HttpServletResponse) response)) response.setCharacterEncoding('UTF-8') response.setContentType('text/plain') def saw = 'АБВГДЕЙКА ЭТО НЕПРОСТАЯ ПЕРЕДАЧА ABCDEFGHIJKLMNOP!!!' def bytes = saw.getBytes('UTF-8') def content = new String(bytes,

draw rectangle on a picture from pixels coordinates

with the following code i can draw a rectangle on my bitmap image. Paint paint = new Paint(); paint.setStyle(Style.STROKE); paint.setColor(Color.BLUE); publishProgress(80); Canvas canvas = new Canvas(mBitmap); publishProgress(85); canvas.drawRect(200, 100, 200, 100, paint); bitmap.recycle(); channel.close(); i've read that the values given in canvas.drawRect(200, 100, 200, 100, paint); represent respectively left x, top y, right x and bottom y. So my questions are : are those values in pixels? ppi or what?? how can i draw a rectangle on my image if i have only the coordinates of each corners in pixels as shown on the picture below ? assuming that i have A (x, y) B (x, y), C(x, y) and D(x, y) with x and y expressed in pixels from the axes of the picture below. NB: i don't have control on A,B,C,D they are given to me from a web service

Unmarshalling returned null object from a successfully marshalled XML

i have the following classes which is marshalled as an XML <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <customer id="100"> <age>21</age> <hobbies> <hobby> <cost>sd</cost> <name>na</name> </hobby> <hobby> <cost>sd</cost> <name>nb</name> </hobby> </hobbies> <name>test</name> </customer> However, when i tried to unmarshall, I can only create the customer object but not hobby, which returns null Am i doing something wrong here? The problem seems to be with the XML hierarchy? package com.mytest.jxb; import java.util.ArrayList; import java.util.List; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlEle

updated gui application

I need to write an application that will check for something every X time and update it to GUI comtols. I have some little knowledge in java and written some applications before but I've never dealt with stuff like multiple threads and updating the GUI. I though it will be an easy task so I've started to write my software. Everything else is pretty much functioning. I just cant get the app to perform checks every X time and then update the GUI. Can someone please give some guidance on this? What shold I look into? what is the common practice? Is it threads? recursive? anything else? Also if possible provide me some code examples, I can understand better. thanks for any effort!

unexpected output while converting a string to date in java

I have a string "12/9/2010 4:39:38 PM" which i have to convert to a date object. I am using the following code to do it: String str = "12/9/2010 4:39:38 PM"; DateFormat formatter ; Date date ; formatter = new SimpleDateFormat("M/dd/yyyy H:m:s a"); date =(Date)formatter.parse(str); System.out.println("date printed"+date); However, when im printing the output, i see Thu Dec 09 04:39:38 IST 2010 How do I get the date exactly the way I declared in the string i.e 12/9/2010 4:39:38 PM as output? Pls help

Two random number generators (card dealing)

I need help with this part of my code. This part deals with generating 2 random numbers and using that random number to display a card in each of 2 label boxes simultaneously. The problem here is the random numbers are not getting generated properly and thus cards are not displayed properly (there is repetition, sometimes no display, etc) Basics of my code: Let us assume h, which is a variable from another part of the code, is any number between 1 and 53 (each number pertaining to a card). If the random number generated (non-repetition) matches the variable h the timer stops. So its basically like having a deck of cards and dealing out the cards evenly to 2 people, but here the dealing stops once a number pertaining to a card (number) randomly taken is matched. (l3,l4 are label names) Global variables: Random rng = new Random(); List<Integer> generated = new ArrayList<Integer>(); List<Integer> generated2 = new ArrayList<Integer>(); int l3coun

JBoss/Java and SSL

Hi I'm a bit lost and hope you'll get me out of here. I'll try to be as clear as possible since I don't really understand/know how I should use certificates. I've got an application that is supposed to communicate with another one using webservices and SSL. We both asked our main "Certificate Authority" to get certificates. They sent us 4 files and a password for the .P12 file: .csr, .cer, .key, .P12 Here is what I did : * Configure JBoss to use SSL on 8443 and used the P12 file as the keystore To test this I did a small Java class that call a webservices on this server, using : props.setProperty("javax.net.ssl.trustStore", "/.../.../certif.p12"); props.setProperty("javax.net.ssl.trustStorePassword", "XXXXXXXXX"); props.setProperty("javax.net.ssl.trustStoreType", "PKCS12"); The connection works, but I think I'm missing something as I did not use the other files. If I send my .P12 file

JGoodies is blocking my action events from firing

I added an actionListener to my JTextField. The JTextField is creating by JGoodies and is buffered. If I change the value in my JTextField and hit enter on it, it fires my event. If I change the value, lose focus, come back and then hit enter, no event fires. Has this happened to anybody else? Any suggestions would be welcome, I am really stuck... ValueModel valueModel = getValueModel(adapter, propertyName, useBuffer); JTextField textField = BasicComponentFactory.createLongField(valueModel); I add an actionListener to it. It works if I change the value and then hit enter. If I change the value, lose focus, and then regain focus and hit enter, the action does not fire, which is unexpected.

How to nest objects when building JSON with JSONObject

I'm trying to encode this string for a POST request. Can anyone tell me how I can encode {"jsonrpc": "2.0", "method": "Files.GetSources", "params":{"media":"music"}, "id": 1} So far I have JSONOjbect obj = new JSONObject(); obj.put("jsonrpc", "2.0"); obj.put("method", "Files.GetSources"); But I'm not sure how to put in the rest - can anyone help?

Object Oriented Programming: More than just basic objects

I seem to find all documentation regarding OOP too basic or too advanced. I'm trying to solve a specific problem and I can't get a nice solution without having to use Singletons or global instances or the such. I'm trying to create a DB based application: I have a DB with Boxes that are stored in some Location. So I created to tables: Boxes and Locations BOXES | id | Name | Location | ------------------------ | 1 | AA | 1 | | 2 | AB | 2 | LOCATIONS | id | Name | --------------------- | 1 | Garage | | 2 | Living Room | When trying to bring this to an Java application, I want to have a Box class that I can instantiate for every box and locations that I have in DB and put them in a list. My question is: how do I design Box and Location Classes? The immediate approach would be: class Box { int id; String name; Location location; } Class Location { int id; String name; } But then, how can I operate Locations properly?

DiskStore .throwableSafeExpireElementsIfRequired(620) org.appfuse.model.User Cache: Could not expire elements from disk due to null

I am facing above exception followed by OutOfMemoryException. JVMDUMP013I Processed Dump Event "systhrow", detail "java/lang/OutOfMemoryError". ERROR [Store org.appfuse.model.User Spool Thread] DiskStore.throwableSafeExpireElementsIfRequired(620) | org.appfuse.model.User Cache: Could not expire elements from disk due to null. Continuing... java.lang.OutOfMemoryError at java.util.Collections$SynchronizedMap . values (Unknown Source) at net.sf.ehcache.store.DiskStore . expireElements at net.sf.ehcache.store. DiskStore . Exception in thread "QuartzScheduler_QuartzSchedulerThread" java.lang.OutOfMemoryError at java.lang.String.<init>(String.java:364) at org.quartz.Trigger.getFullName(Trigger.java:435) at org.quartz.simpl.TriggerComparator.compare(RAMJobStore.java:1408) at java.util.TreeMap.find(Unknown Source) at java.util.TreeMap.remove(Unknown Source) at java.util.TreeSet.remove(Unknown

" The crash happened outside the Java Virtual Machine in native code.&rdquo;how to solve this error (Java)?

Using the library in this link http://www.blog.kslemb.com/doku.php/en/projects/globx/java_hid I have been modfied this code to write on a HID terminal if (HIDHandle.equals(WinBase.INVALID_HANDLE_VALUE)) { return HID_DEVICE_NOT_OPENED; } /* Write Feature report */ boolean Status=Kernel32.INSTANCE.WriteFile(HIDHandle, buffer, (int)buffersize, null, null); if (Status == false) { debug("Write File: " + getSystemError(Kernel32.INSTANCE.GetLastError())); return HID_DEVICE_TRANSFER_FAILED; } else { return HID_DEVICE_SUCCESS; } This code would successfully writes on the HID device but then it would produce this error A fatal error has been detected by the Java Runtime Environment: # # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x7600d4d5, pid=4660, tid=3780 # # JRE version: 6.0_27-b07 # Java VM: Java HotSpot(TM) Client VM (20.2-b06 mixed mode, sharing windows-x86 ) # Problematic frame: # C [KERNELBASE.dll+0xd4d5] # # An error report file with more informati

Java: Best way to store to an arbitrary index of an ArrayList

I know that I cannot store a value at an index of an ArrayList that hasn't been used yet, i.e. is less than the size. In other words, if myArrayList.size() is 5, then if I try to do myArrayList.set(10, "Hello World") I will get an out of bounds error. But my app needs this. Other than a loop of storing null in each of the intermediate slots, is there a more elegant way? It looks to me like: This behavior is the same in Vector If I need to be able to randomly access (i.e. element at pos X) then my choices are Vector and ArrayList. I could use a HashMap and use the index as a key but that's really inefficient. So what is the elegant solution to what looks like a common case. I must be missing something...

Can I have an activity create another activity and wait for it to return information?

I want the user to be able to click a button and move to a different activity to input some information and then press a button to "submit" that information to the previous screen. Home Screen --button press--> Input Screen --"submit"--> Home Screen Is there a way to start the input screen activity and have the home screen wait for a response? This is the code I have now. Intent inputIntent = new Intent(this, InputActivity.class); try { // Attempt to start the activity startActivity(inputIntent); return true; } catch(ActivityNotFoundException e) { System.out.println("Cannot find activity for intent: " + inputIntent.toString()); return false; } I guess not only am I asking how to have the home screen "wait," but it would also be ideal to get back to the same home screen (not creating a NEW homescreen from the input screen).

Common sequences in two strings [closed]

I am looking to find all common sequences of works between two strings. For example: String A: A, B, 1, 2, 3, 4, 5, X String B: 1, 2, 3, 4, A, B, C The common sequences here would be A, B & 1, 2, 3, 4 I am looking for a Java solution which will do this. Thank you very much

Can I demultiplex streams?

I want to join stderr ( getErrorStream ) and stdout ( getInputStream ) of a Process into a single Stream to be consumed elsewhere. Is there anything in Java's library that will do that for me? Note: no external libraries . I'm not interested in the existence of a solution provided by, say, Apache Commons IO. I only want to know if there's something that comes with JDK.

Why this table In-Cell editor, doesnt work?

I am trying to figure out, how the primefaces in-cell editor works. For some reason, it does not work. I just see it activating and also i can type, but the values do not change. What is missing? <?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"> <h:form> <p:dataTable id="allSubjects" var="subject" value="#{subjectControllerUpdate.retrieve()}" paginator="true" rows="7" > <p:column headerText="Name" sortBy="#{subject.name}" style="width:200px" > <p:cellEditor>

Get files from Jar which is on the repository without downloading the whole Jar from Java

I would like to access the jar file on the repository, search inside it for the certain files, retrieve those files and store them on my hard disc. I don't want to download the whole jar and then to search for it. So let's assume I have the address of the Jar. Can someone provide me with the code for the rest of the problem? public void searchInsideJar(final String jarUrl, final String artifactId, final String artifactVersion) { InputStream is = null; OutputStream outStream = null; JarInputStream jis = null; int i = 1; try { String strDirectory = "C:/Users/ilijab/" + artifactId +artifactVersion; // Create one directory boolean success = (new File(strDirectory)).mkdir(); if (success) { System.out.println("Directory: " + strDirectory + " created"); } is = new URL(jarUrl).openStream(); jis = new JarInputStream(is); while (true) { J

How can I hide long class paths in stack traces to make them readable?

Often stack traces can get so verbose from long class paths that they are very painful to read. Here's an example: 1) No implementation for java.util.Set< com.mydomain.myapp.android.activities.catbrowser.generalizedbrowser.listview. helpers.databaseitem.itemmanipulators.ItemManipulator< com.mydomain.myapp.flash.Cat>> annotated with @com.google.inject.assistedinject.Assisted(value=) was bound. while locating java.util.Set< com.mydomain.myapp.android.activities.catbrowser.generalizedbrowser.listview. helpers.databaseitem.itemmanipulators.ItemManipulator< com.mydomain.myapp.flash.Cat>> annotated with @com.google.inject.assistedinject.Assisted(value=) ... If I could trim the class path, only showing class names and methods, it would look like this: 1) No implementation for Set<ItemManipulator<Cat>> annotated with @Assisted(value=) was bound. while locating Set<ItemManipulator<Cat>> annotated with @Assisted(v

Using DISTINCT keyword in JPA on individual columns

I am reading some values from a database that is horribly un-normalized (which I can't control). The call retrieves announcements for university departments, and if a user is in multiple departments (which is possible), then the same results are returned multiple times for these users. However, some departments might have different announcements, while some have the same. Is there a way for me to use the DISTINCT keyword in JPA on individual columns? This is what I currently have for the query: String jpql = "SELECT DISTINCT annoucement FROM Announcment announcement " + "WHERE (announcement.date <= :now AND announcement.endDate >= :now) " + "AND announcement.approved = true AND announcement.departmentId IN (:departmentIDs)"; TypedQuery<Announcement> query = entityManager.createQuery(jpql, Announcement.class); query.setParameter("now", new Date()); query.setParameter("departm

Preventing Java from printing the stack trace on certain exceptions

I have a security class that throws an AccessDeniedException on a user not being authorized for a certain operation. I made it even neat and put a msg in there with the info I need. The problem is that now my logs are full of stack traces for every single time I throw. I don't care to see the stack trace for THIS exception, and the stack traces are bloating my logs. Is there a way to tell Java not to print the stack trace to the logs if it's this exception? Thanks! -- llappall

How to refresh BlackBerry ui page on button click?

I may seem ignorant but I have not found much information about how to go about my problem developing my BlackBerry application. Basically I have constructed a UI that contains a few image buttons. What I want to do is when I click on one of the buttons, I want an image at the center of the screen to switch seemlessly to another image. I am currently not using any threads though from what I've gathered I need to? Or do I simply have to push a new screen in my button listener and recall the class's constructor and rebuild the page with different images? Sorry if this is unclear, I would really appreciate some basic info on how to do this or a link that explains page refreshing in detail for blackberry! Thanks alot EDIT : Okay here is a very small part of my code : This is basically the last thing I have tried in the listeners, I dont know how to change the image (flagField) when I press one of the two buttons! The only thing that worked for me was pushScreen(new