Search Results

Search found 461 results on 19 pages for 'parseint'.

Page 12/19 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • How to get selected row index in JSF datatable?

    - by Nitesh Panchal
    I have a databale on index.xhtml <h:dataTable style="border: solid 2px black;" value="#{IndexBean.bookList}" var="item" binding="#{IndexBean.datatableBooks}"> <h:column> <h:commandButton value="Edit" actionListener="#{IndexBean.editBook}"> <f:param name="index" value="#{IndexBean.datatableBooks.rowIndex}"/> </h:commandButton> </h:column> </h:dataTable> My bean: @ManagedBean(name="IndexBean") @ViewScoped public class IndexBean implements Serializable { private HtmlDataTable datatableBooks; public HtmlDataTable getDatatableBooks() { return datatableBooks; } public void setDatatableBooks(HtmlDataTable datatableBooks) { this.datatableBooks = datatableBooks; } public void editBook() throws IOException{ int index = Integer.parseInt(FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("index").toString()); System.out.println(index); } } My problem is that I always get the same index in server log even though I click the different edit buttons. Imagine that there is one collection which is supplied to the datatable. I have not shown that in bean. If I change scope from ViewScope to RequestScope it works fine. What can be the problem with @ViewScoped? Thanks in advance :) EDIT: <h:column> <h:commandButton value="Edit" actionListener="#{IndexBean.editBook}" /> </h:column> public void editBook(ActionEvent ev) throws IOException{ if (ev.getSource() != null && ev.getSource() instanceof HtmlDataTable) { HtmlDataTable objHtmlDataTable = (HtmlDataTable) ev.getSource(); System.out.println(objHtmlDataTable.getRowIndex()); } }

    Read the article

  • JSF with Enum 'Validation Error: Value is not valid'

    - by Shamik
    I have an enum whose code is like this - public enum COSOptionType { NOTAPPLICABLE, OPTIONAL, MANDATORY; private String[] label = { "Not Applicable", "Optional", "Mandatory"}; @Override public String toString() { return label[this.ordinal()]; } public static COSOptionType getCOSOption(String value) { int ivalue = Integer.parseInt(value); switch(ivalue) { case 0: return NOTAPPLICABLE; case 1: return OPTIONAL; case 2: return MANDATORY; default: throw new RuntimeException("Should not get this far ever!"); } } } I have the converter to convert the enum type public class COSEnumConverter implements Converter { public Object getAsObject(FacesContext context, UIComponent comp, String value) { return COSOptionType.getCOSOption(value); } public String getAsString(FacesContext context, UIComponent comp, Object obj) { if (obj instanceof String) { return (String) obj; } COSOptionType type = (COSOptionType) obj; int index = type.ordinal(); return ""+index; } } The view looks like this <h:selectOneMenu value="#{controller.type}" id="smoking"> <f:selectItems value="#{jnyController.choices}" /> </h:selectOneMenu> Here is the code for create choices private List<SelectItem> createChoicies() { List<SelectItem> list = new ArrayList<SelectItem>(); for (COSOptionType cos : COSOptionType.values()) { SelectItem item = new SelectItem(); item.setLabel(cos.toString()); item.setValue("" + cos.ordinal()); list.add(item); } return list; } I do not understand why this would throw "validation error" all the time ? I can debug and see that the converter is working fine. NOTE: I am using JSF 1.1

    Read the article

  • kendo ui filtering the grid table, need some idea

    - by cool_spirit
    I want to filter the table by last name, but cant work, here is my code in controller public JsonResult Filtering() { HealthContext rc = new HealthContext(); var last = rc.Profiles.Select(lastt => new SelectListItem { Text = lastt.LastName, Value = lastt.Id.ToString() }).ToList(); return Json(last.ToList(), JsonRequestBehavior.AllowGet); } in view <script type="text/x-kendo-template" id="template"> <div class="toolbar"> <label class="category-label" for="Last name"> by last name:</label> <input type="search" id="LastName" style="width: 230px"></input> </div> </script> and also <script> $(document).ready(function() { $("#grid").kendoGrid({ dataSource: { transport: { read: { url: "/Profiles/GetJsonData", dataType: "json" } }, pageSize: 10, }, toolbar: kendo.template($("#template").html()), height: 250, filterable: true, sortable: true, pageable: true, defaultSorting: 'LastName ASC', columns: [{ field: "Id", filterable: false }, { field: "FirstName", title: "First Name", width: 100, }, { field: "LastName", title: "Last Name", width: 200 }, { field: "Gender", title: "Gender" } ] }); var dropDown = grid.find("#LastName").kendoDropDownList({ dataTextField: "LastName", dataValueField: "Id", autoBind: false, optionLabel: "All", dataSource: { severFiltering: true, transport: { read: { url: "/Profiles/Filtering", dataType: "json" } }, }, change: function() { var value = this.value(); if (value) { grid.data("kendoGrid").dataSource.filter({ field: "Id", operator: "eq", value: parseInt(value) }); } else { grid.data("kendoGrid").dataSource.filter({}); } } }); }); </script> so the problem is the drop down list is not show up as well as the value/ data, any idea guys?

    Read the article

  • Javascript help fixing a working time ago date function to simply show seconds ago.

    - by Scarface
    Hey guys quick question, I am using a javascript function and it works except I can only make it say 0 seconds ago, when the time is under a minute. Can anyone quickly explain what I am doing wrong? function handleDate( timestamp ) { var n=new Date(), t, ago = " "; if( timestamp ) { t = Math.round( (n.getTime()/1000 - timestamp)/60 ); ago += handleSinceDateEndings( t, timestamp ); } else { ago += ""; } return ago; } function handleSinceDateEndings( t, original_timestamp ) { var ago = " ", date; if( t <= 1 ) { ago += t + " seconds ago"; } else if( t<60) { ago += t + " mins ago"; } else if( t>= 60 && t<= 120) { ago += Math.floor( t / 60 ) + " hour ago" } else if( t<1440 ) { //console.log(t) ago += Math.floor( t / 60 ) + " hours ago"; } else if( t< 2880) { ago += "1 day ago"; } else if( t > 2880 && t < 4320 ) { ago += "2 days ago"; } else { date = new Date( parseInt( original_timestamp )*1000 ) ago += months[ date.getMonth() ] + " " + date.getDate(); } return ago; } var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];

    Read the article

  • jQuery: script remember values between times it is triggered?

    - by Marius
    Hello there, I am writing an ajax script in jQuery. The script gets new or previous page from a php documents that returns HTML. If, located on page 1, I click next, the script IS able to find the next page number (page2), but when I click it AGAIN, the script again has to be able to find the next page number (page3) and at the minute it doesnt. I was wondering how I can save a variable between time a script is triggered, so that I can just + 1 to each time somebody clicks "next", and -1 when somebody clicks "previous". This is my code: $('.buttonNeste').click(function(event){ event.preventDefault(); if (page == null || id == null ) { var page = parseInt($(this).closest('.paginationFullWidth').attr('id')) + 1; var id = $(this).closest('.paginationFullWidth').siblings('.jtextfill').children('h1').attr('id'); } else { var page = page + 1; } var target = $(this); $.post( 'http://www.example.com/controllers/foo.php', { 'page': ( page ), 'id': id }, function(data) { $(target).closest('.paginationFullWidth').siblings('.commentsContainer').html(data); }); }); Thank you for your time. Kind regards, Marius

    Read the article

  • jquery loop to create elements with retained values

    - by Andy Simpson
    Dear all, I recently asked a question about creating elements with jquery. Specifically I needed input boxes created/deleted depending on the value of a particular select box. This was answered quickly with a very nice solution as follows: $('select').change(function() { var num = parseInt($(this).val(), 10); var container = $('<div />'); for(var i = 1; i <= num; i++) { container.append('<input id="id'+i+'" name="name'+i+'" />'); } $('somewhere').html(container); }); This works very well. Is there a way to have the values remaining in the text boxes when the selection is changed? For example, lets say the select element value is set to '2' so that there are 2 input boxes showing. If there is input already entered in these boxes and the user changes the select element value to '3' is there a way to get the first 2 input boxes to retain their value? Thanks for the help in advance Andy

    Read the article

  • JFreeChart - change SeriesStroke of chart lines from solid to dashed in one line

    - by MisterMichaelK
    The answer accepted here (JFreechart(Java) - How to draw lines that is partially dashed lines and partially solid lines?) helped me start down the path of changing my seriesstroke lines on my chart. After stepping through my code and watching the changes, I see that my seriesstroke does in fact change to "dashedStroke" when it is supposed to (after a certain date "dai"), but when the chart is rendered the entire series line is dashed. How can I get a series line to be drawn solid at first and dashed after a set date? /* series line modifications */ final Number dashedAfter = timeNowDate.getTime(); final int dai = Integer.parseInt(ndf.format(timeNowDate)); XYLineAndShapeRenderer render = new XYLineAndShapeRenderer() { Stroke regularStroke = new BasicStroke(); Stroke dashedStroke = new BasicStroke( 1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] {10.0f, 6.0f}, 0.0f ); @Override public Stroke getItemStroke(int row, int column) { Number xVal = cd.getXValue(row, column); int xiv = xVal.intValue(); if (xVal.doubleValue() > dashedAfter.doubleValue()) { return dashedStroke; } else { return regularStroke; } } }; plot.setRenderer(render);

    Read the article

  • ASP.NET required field validator firing on focus in Firefox

    - by ren33
    I have 2 asp.net textboxes in an update panel. Both textbox controls have some javascript attached to autotab to the next field and to allow only numeric input. When I enter some data into the first field and press enter, focus shifts to the next field and the requiredfieldvalidator of the second field displays its "* required" error message, even though I've just entered the field. This is only happening in Firefox. How can I prevent the validator from firing when I first enter the textbox? edit Here's the code: <asp:TextBox ID="add_ISBN" runat="server" Columns="14" MaxLength="17" CssClass="focus" /> <asp:TextBox ID="add_Qty" runat="server" Columns="4" MaxLength="4" /> <asp:RequiredFieldValidator ID="rfvQty" ControlToValidate="add_Qty" ErrorMessage="* required" ForeColor="Red" Display="Dynamic" EnableClientScript="true" ValidationGroup="Add" runat="server" /> In the codebehind: add_ISBN.Attributes.Add("onkeydown", "return isbnCheck(event, '" & add_Qty.ClientID & "')") And the javascript: function isbnCheck(e, id) { e = e || window.event; var key = e.which || e.keyCode if (validIsbnChars.indexOf(parseInt(key, 10)) >= 0) { return true; } else { if (key == 13) { var nextfield = document.getElementById(id); if (nextfield) nextfield.focus(); return false; } if (e.preventDefault) e.preventDefault(); e.returnValue = false; return false; } } The javascript allows only a valid subset of characters, and if the user presses enter, sets focus to the next field.

    Read the article

  • How to call a new thread from button click

    - by Lynnooi
    Hi, I'm trying to call a thread on a button click (btn_more) but i cant get it right. The thread is to get some data and update the images. The problem i have is if i only update 4 or 5 images then it works fine. But if i load more than 5 images i will get a force close. At times when the internet is slow I will face the same problem too. Can please help me to solve this problem or provide me some guidance? Here is the error i got from LogCat: 04-19 18:51:44.907: ERROR/AndroidRuntime(1034): Uncaught handler: thread main exiting due to uncaught exception 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): java.lang.NullPointerException 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): at mobile9.android.gallery.GalleryWallpapers.setWallpaperThumb(GalleryWallpapers.java:383) 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): at mobile9.android.gallery.GalleryWallpapers.access$4(GalleryWallpapers.java:320) 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): at mobile9.android.gallery.GalleryWallpapers$1.handleMessage(GalleryWallpapers.java:266) 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): at android.os.Handler.dispatchMessage(Handler.java:99) 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): at android.os.Looper.loop(Looper.java:123) 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): at android.app.ActivityThread.main(ActivityThread.java:4310) 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): at java.lang.reflect.Method.invokeNative(Native Method) 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): at java.lang.reflect.Method.invoke(Method.java:521) 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): at dalvik.system.NativeStart.main(Native Method) My Code: public class GalleryWallpapers extends Activity implements Runnable { public static String MODEL = android.os.Build.MODEL ; private static final String rootURL = "http://www.uploadhub.com/mobile9/gallery/c/"; private int wallpapers_count = 0; private int ringtones_count = 0; private int index = 0; private int folder_id; private int page; private int page_counter = 1; private String family; private String keyword; private String xmlURL = ""; private String thread_op = "xml"; private ImageButton btn_back; private ImageButton btn_home; private ImageButton btn_filter; private ImageButton btn_search; private TextView btn_more; private ProgressDialog pd; GalleryExampleHandler myExampleHandler = new GalleryExampleHandler(); Context context = GalleryWallpapers.this.getBaseContext(); Drawable image; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); MODEL = "HTC Legend"; // **needs to be remove after testing** try { MODEL = URLEncoder.encode(MODEL,"UTF-8"); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.gallerywallpapers); Bundle b = this.getIntent().getExtras(); family = b.getString("fm").trim(); folder_id = Integer.parseInt(b.getString("fi")); keyword = b.getString("kw").trim(); page = Integer.parseInt(b.getString("page").trim()); WindowManager w = getWindowManager(); Display d = w.getDefaultDisplay(); final int width = d.getWidth(); final int height = d.getHeight(); xmlURL = rootURL + "wallpapers/1/?output=rss&afm=wallpapers&mdl=" + MODEL + "&awd=" + width + "&aht=" + height; if (folder_id > 0) { xmlURL = xmlURL + "&fi=" + folder_id; } pd = ProgressDialog.show(GalleryWallpapers.this, "", "Loading...", true, false); Thread thread = new Thread(GalleryWallpapers.this); thread.start(); btn_more = (TextView) findViewById(R.id.btn_more); btn_more.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { myExampleHandler.filenames.clear(); myExampleHandler.authors.clear(); myExampleHandler.duration.clear(); myExampleHandler.fileid.clear(); btn_more.setBackgroundResource(R.drawable.btn_more_click); page = page + 1; thread_op = "xml"; xmlURL = rootURL + "wallpapers/1/?output=rss&afm=wallpapers&mdl=" + MODEL + "&awd=" + width + "&aht=" + height; xmlURL = xmlURL + "&pg2=" + page; index = 0; pd = ProgressDialog.show(GalleryWallpapers.this, "", "Loading...", true, false); Thread thread = new Thread(GalleryWallpapers.this); thread.start(); } }); } public void run() { if(thread_op.equalsIgnoreCase("xml")){ readXML(); } else if(thread_op.equalsIgnoreCase("getImg")){ getWallpaperThumb(); } handler.sendEmptyMessage(0); } private Handler handler = new Handler() { @Override public void handleMessage(Message msg) { int count = 0; if (!myExampleHandler.filenames.isEmpty()){ count = myExampleHandler.filenames.size(); } count = 6; if(thread_op.equalsIgnoreCase("xml")){ pd.dismiss(); thread_op = "getImg"; btn_more.setBackgroundResource(R.drawable.btn_more); } else if(thread_op.equalsIgnoreCase("getImg")){ setWallpaperThumb(); index++; if (index < count){ Thread thread = new Thread(GalleryWallpapers.this); thread.start(); } } } }; private void readXML(){ if (xmlURL.length() != 0) { try { /* Create a URL we want to load some xml-data from. */ URL url = new URL(xmlURL); /* Get a SAXParser from the SAXPArserFactory. */ SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser sp = spf.newSAXParser(); /* Get the XMLReader of the SAXParser we created. */ XMLReader xr = sp.getXMLReader(); /* * Create a new ContentHandler and apply it to the * XML-Reader */ xr.setContentHandler(myExampleHandler); /* Parse the xml-data from our URL. */ xr.parse(new InputSource(url.openStream())); /* Parsing has finished. */ /* * Our ExampleHandler now provides the parsed data to * us. */ ParsedExampleDataSet parsedExampleDataSet = myExampleHandler .getParsedData(); } catch (Exception e) { //showDialog(DIALOG_SEND_LOG); } } } private void getWallpaperThumb(){ int i = this.index; if (!myExampleHandler.filenames.elementAt(i).toString().equalsIgnoreCase("")){ image = ImageOperations(context, myExampleHandler.thumbs.elementAt(i).toString(), "image.jpg"); } } private void setWallpaperThumb(){ int i = this.index; if (myExampleHandler.filenames.elementAt(i).toString() != null) { String file_info = myExampleHandler.filenames.elementAt(i).toString(); String author = "\nby " + myExampleHandler.authors.elementAt(i).toString(); final String folder = myExampleHandler.folder_id.elementAt(folder_id).toString(); final String fid = myExampleHandler.fileid.elementAt(i).toString(); ImageView imgView = new ImageView(context); TextView tv_filename = null; TextView tv_author = null; switch (i + 1) { case 1: imgView = (ImageView) findViewById(R.id.image1); tv_filename = (TextView) findViewById(R.id.filename1); tv_author = (TextView) findViewById(R.id.author1); break; case 2: imgView = (ImageView) findViewById(R.id.image2); tv_filename = (TextView) findViewById(R.id.filename2); tv_author = (TextView) findViewById(R.id.author2); break; case 3: imgView = (ImageView) findViewById(R.id.image3); tv_filename = (TextView) findViewById(R.id.filename3); tv_author = (TextView) findViewById(R.id.author3); break; case 4: . . . . . case 10: imgView = (ImageView) findViewById(R.id.image10); tv_filename = (TextView) findViewById(R.id.filename10); tv_author = (TextView) findViewById(R.id.author10); break; } if (image.getIntrinsicHeight() > 0) { imgView.setImageDrawable(image); } else { imgView.setImageResource(R.drawable.default_wallpaper); } tv_filename.setText(file_info); tv_author.setText(author); imgView.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { // Perform action on click } }); } } private Drawable ImageOperations(Context ctx, String url, String saveFilename) { try { InputStream is = (InputStream) this.fetch(url); Drawable d = Drawable.createFromStream(is, "src"); return d; } catch (MalformedURLException e) { e.printStackTrace(); return null; } catch (IOException e) { e.printStackTrace(); return null; } } }

    Read the article

  • Problem with Spring @Configuration class

    - by easyrider
    Hi, i use class with @Configuration annotation to configure my spring application: @Configuration public class SpringConfiguration { @Value("${driver}") String driver; @Value("${url}") String url; @Value("${minIdle}") private int minIdle; // snipp .. @Bean(destroyMethod = "close") public DataSource dataSource() { DataSource dataSource = new DataSource(); dataSource.setDriverClassName(driver); dataSource.setUrl(url); dataSource.setUsername(user); dataSource.setPassword(password); dataSource.setMinIdle(minIdle); return dataSource; } and properties file in CLASSPATH driver=org.postgresql.Driver url=jdbc:postgresql:servicerepodb minIdle=1 I would like to get my DataSource configured object in my DAO class: ApplicationContext ctx = new AnnotationConfigApplicationContext(SpringConfiguration.class); DataSource dataSource = ctx.getBean(DataSource.class); But i get the error: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private int de.hska.repo.configuration.SpringConfiguration.minIdle; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert value of type 'java.lang.String' to required type 'int'; nested exception is **java.lang.NumberFormatException: For input string: "${minIdle}"** Caused by: java.lang.NumberFormatException: For input string: **"${minIdle}"** at java.lang.NumberFormatException.forInputString(**Unknown Source**) at java.lang.Integer.parseInt(Unknown Source) at java.lang.Integer.valueOf(Unknown Source) It worked with String properties (driver, url), but ${minIdle} (of type int) can't be resolved! Please help. Thanx in advance!

    Read the article

  • Cannot find symbol - variable

    - by Ben Garside
    I'm new to Java, and I'm trying to get user input, store each line of input as a variable and then return each value so that it can be passed on somewhere else. When I try and compile it is telling me that it can't find the variable magnitude. I'm assuming it won't find the others either. I'm guessing that this is because I've declare the variables inside of the "try" but don't know how to get it so that the return statement accepts them. Code is as follows: public Earthquake userAddEarthquake() { Scanner scanner = new Scanner(System.in); try{ // convert the string read from the scanner into Integer type System.out.println("Please Enter An Earthquake Magnitude: "); Double magnitude = Double.parseDouble(scanner.nextLine()); System.out.println("Please Enter The Earthquakes Latitude Position: "); scanner = new Scanner(System.in); Double positionLatitude = Double.parseDouble(scanner.nextLine()); System.out.print("Please Enter The Earthquakes Longitude Position: "); scanner = new Scanner(System.in); Double positionLongitude = Double.parseDouble(scanner.nextLine()); System.out.print("Please Enter The Year That The Earthquake Occured: "); scanner = new Scanner(System.in); int year = Integer.parseInt(scanner.nextLine()); System.out.println("Magnitude = " + magnitude); } catch(NumberFormatException ne){ System.out.println("Invalid Input"); } finally{ scanner.close(); } return new Earthquake(magnitude, positionLatitude, positionLongitude, year); }

    Read the article

  • Can't get past 2542 Threads in Java on 4GB iMac OSX 10.6.3 Snow Leopard (32bit)

    - by fuzzy lollipop
    I am running the following program trying to figure out how to configure my JVM to get the maximum number of threads my machine can support. For those that might not know, Snow Leopard ships with Java 6. I tried starting it with defaults, and the following command lines, I always get the Out of Memory Error at Thread 2542 no matter what the JVM options are set to. java TestThreadStackSizes 100000 java -Xss1024 TestThreadStackSizes 100000 java -Xmx128m -Xss1024 TestThreadStackSizes 100000 java -Xmx2048m -Xss1024 TestThreadStackSizes 100000 java -Xmx2048m -Xms2048m -Xss1024 TestThreadStackSizes 100000 no matter what I pass it, I get the same results, Out of Memory Error at 2542 public class TestThreadStackSizes { public static void main(final String[] args) { Thread.currentThread().setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { public void uncaughtException(final Thread t, final Throwable e) { System.err.println(e.getMessage()); System.exit(1); } }); int numThreads = 1000; if (args.length == 1) { numThreads = Integer.parseInt(args[0]); } for (int i = 0; i < numThreads; i++) { try { Thread t = new Thread(new SleeperThread(i)); t.start(); } catch (final OutOfMemoryError e) { throw new RuntimeException(String.format("Out of Memory Error on Thread %d", i), e); } } } private static class SleeperThread implements Runnable { private final int i; private SleeperThread(final int i) { this.i = i; } public void run() { try { System.out.format("Thread %d about to sleep\n", this.i); Thread.sleep(1000 * 60 * 60); } catch (final InterruptedException e) { throw new RuntimeException(e); } } } } Any ideas on now I can affect these results?

    Read the article

  • Jsp page getting called from cache rather than getting loaded from server

    - by sam4u-optimistic86
    I am calling a jsp based on 2 parameters which is passed from jsp 1 in this way.Below i pass 2 parameters into 2.jsp and based on these 2 parameters data is displayed in 2.jsp.I have a loop in which i have a number of hrefs like the one i have described below.Each of these href passes a different set of value to 2.jsp. out.println("<a href=\"2.jsp?prId=" + prog.getId() + count + "\">" + prog.getName() + "</a>"); I retrieve these 2 parameters in 2.jsp using the following lines count_id = request.getParameter( "country_id" ); prog_id = Integer.parseInt(request.getParameter( "program_id" )); Based on these 2 parameters i show the corresponding data in 2.jsp Now i have a back button in 2.jsp and i call 1.jsp in 2.jsp using the following code <a href="1.jsp"><img src="/image/back.gif" border="0"></a> The problem is when i use the back button and go back to 1.jsp and select another href like the one i have described above i get the data related to the previous href selected. I guess the problem is when i request the page is loaded from cache rather than from the server. Please advice

    Read the article

  • Need AngularJS grid resizing directive to resize "thumbnail" that contains no image

    - by thebravedave
    UPDATE Plunker to project: http://plnkr.co/edit/oKB96szQhqwpKQbOGUDw?p=preview I have an AngularJS project that uses AngularJS Bootstrap grids. I need all of the grid elements to have the same size so they stack properly. I created an angularJs directive that auto resizes the grid element when placed in said grid element. I have 2 directives that do this for me Directive 1: onload Directive 2: imageonload Directive 2 works. If the grid element uses an image, after the image loads then the directive triggers an event that sends the grid elements height to all other grid elements. If that height sent out via the event is greater than that of the grid element which is listening to the event then that listening grid element changes it's height to be the greater height. This way the largest height becomes the height for all the grid elements. Directive 1 does not work. This one is placed on the outer most grid elements html element, and is triggered when the element loads. The problem is that when the element loads and the onload directive is called AngularJS has not yet filled out the data in said grid element. The outcome is that the real height after AngularJS data binds is not broadcast as an event. My only solution I have thought of (but haven't tried) is to add an image url to an image that exists but doesn't have any data in it, and place that in the grid element (the one that didn't have any images before placing the blank one in). I could then call imageonload instead of onload and I pretty sure the angularjs data binding will have taken place by then. the problem is that that is pretty hacky. I would rather be able to have not an image in the grid element, and be able to call my custom onload directive and have the onload directive calculate the height AFTER angularJS data binds to all of the data binding variables in the grid element. Here is my imageonload directive .directive('imageonload', function($rootScope) { return { restrict: 'A', link: function(scope, element, attrs) { scope.heightArray = []; scope.largestHeight = 50; element.bind('load', function() { broadcastThumbnailHeight(); }); scope.$on('imageOnLoadEvent', function(caller, value){ var el = angular.element(element); var id = el.prop('id'); var pageName = el.prop('title'); if(pageName == value[0]){ if(scope.largestHeight < value[1]){ scope.largestHeight = value[1]; var nestedString = el.prop('alt'); if(nestedString == "") nestedString = "1"; var nested = parseInt(nestedString); nested = nested - 1; var inte = 0; var thumbnail = el["0"]; var finalThumbnailContainer = thumbnail.parentElement; while(inte != nested){ finalThumbnailContainer = finalThumbnailContainer.parentElement; inte++; } var innerEl = angular.element(finalThumbnailContainer); var height = value[1]; innerEl.height(height); } } }); scope.$on('findHeightAndBroadcast', function(){ broadcastThumbnailHeight(); }); scope.$on('resetThumbnailHeight', function(){ scope.largestHeight = 50; }); function broadcastThumbnailHeight(){ var el = angular.element(element); var id = el.prop('id'); var alt = el.prop('alt'); if(alt == "") alt = "1"; var nested = parseInt(alt); nested = nested - 1; var pageName = el.prop('title'); var inte = 1; var thumbnail = el["0"]; var finalThumbnail = thumbnail.parentElement; while(inte != nested){ finalThumbnail = finalThumbnail.parentElement; inte++; } var elZero = el["0"]; var clientHeight = finalThumbnail.clientHeight; var arr = []; arr[0] = pageName; arr[1] = clientHeight; $rootScope.$broadcast('imageOnLoadEvent', arr); } } }; }) And here is my onload directive .directive('onload', function($rootScope) { return { restrict: 'A', link: function(scope, element, attrs) { scope.largestHeight=100; getHeightAndBroadcast(); scope.$on('onLoadEvent', function(caller, value){ var el = angular.element(element); var id = el.prop('id'); var pageName = el.prop('title'); if(pageName == value[0]){ if(scope.largestHeight < value[1]){ scope.largestHeight = value[1]; var height = value[1]; el.height(height); } } }); function getHeightAndBroadcast(){ var el = angular.element(element); var h = el["0"].children; var thumbnailHeightElement = angular.element(h); var pageName = el.prop("title"); var clientHeight = thumbnailHeightElement["0"].clientHeight; var arr = []; arr[0] = pageName; arr[1] = clientHeight; if(clientHeight != undefined) $rootScope.$broadcast('onLoadEvent', arr); } } }; }) Here is an example of one of my grid elements that uses imageonload. Note the imageonload directive in the image html element. This works. There is also an onload directive on the outer most html of the grid element. That does not work. I have stepped through this carefully in Firebug and saw that the onload was calculating the height before AngularJS data binding was complete. <div class="thumbnail col-md-3" id="{{product.id}}" title="thumbnailAdminProductsGrid" onload> <div class="row"> <div class="containerz"> <div class="row-fluid"> <div class="col-md-2"></div> <div class="col-md-7"> <div class="textcenterinline"> <!--tag--><img class="img-responsive" id="{{product.id}}" title="imageAdminProductsGrid" alt=6 ng-src="{{product.baseImage}}" imageonload/><!--end tag--> </div> </div> </div> <div class="caption"> <div class="testing"> <div class="row-fluid"> <div class="col-md-12"> <h3 class=""> <!--tag--><a href="javascript:void(0);" ng-click="loadProductView('{{product.id}}')">{{product.name}}</a><!--end tag--> </h3> </div> </div> <div class="row-fluid"> <div class="col-md-12"> <p class="lead"><!--tag--> {{product.price}}</p><!--end tag--> </div> </div> <div class="row-fluid"> <div class="col-md-12"> <p><!--tag-->{{product.inStock}} units available<!--end tag--></p> </div> </div> <div class="row-fluid"> <div class="col-md-12"> <p class=""><!--tag-->{{product.generalDescription}}<!--end tag--></p> </div> </div> <!--tag--> <div data-ng-if="product.specialized=='true'"> <div class="row-fluid"> <div class="col-md-12" ng-repeat="varCat in product.varietyCategoriesAndOptions"> <b><h4>{{varCat.varietyCategoryName}}</h4></b> <select ng-model="varCat.varietyCategoryOption" ng-options="value.varietyCategoryOptionId as value.varietyCategoryOptionValue for (key,value) in varCat.varietyCategoryOptions"> </select> </div> </div> </div> <!--end tag--> <div class="row-fluid"> <div class="col-md-12"> <!--tag--><div ng-if="product.weight==0"><b>Free Shipping</b></div><!--end tag--> </div> </div> </div> </div> </div> </div> Here is an example of one of the html for one of my grid elements that only uses the "onload" directive and not "imageonload" <div class="thumbnail col-md-3" title="thumbnailCouponGrid" onload> <div class="innnerContainer"> <div class="text-center"> {{coupon.name}} <br /> <br /> <b>Description</b> <br /> {{coupon.description}} <br /> <br /> <button class="btn btn-large btn-primary" ng-click="goToCoupon()">View Coupon Details</button> </div> </div> The imageonload function might look a little confusing because I use the img html attribute "alt" to signal to the directive how many levels the imageonload is placed below the outermost html for the grid element. We have to have this so the directive knows which html element to set the new height on. also I use the "title" attribute to set which grid this grid resizing is for (that way you can use the directive multiple times on the same page for different grids and not have the events for the wrong grid triggered). Does anyone know how I can get the "onload" directive to get called AFTER angularJS binds to the grid element? Just for completeness here are 2 images (almost looks like just 1), the second is a grid that contains grid elements that have images and use the "imageonload" directive and the first is a grid that contains grid elements that do not use images and only uses the "onload" directive.

    Read the article

  • Project Euler (P14): recursion problems

    - by sean mcdaid
    Hi I'm doing the Collatz sequence problem in project Euler (problem 14). My code works with numbers below 100000 but with numbers bigger I get stack over-flow error. Is there a way I can re-factor the code to use tail recursion, or prevent the stack overflow. The code is below: import java.util.*; public class v4 { // use a HashMap to store computed number, and chain size static HashMap<Integer, Integer> hm = new HashMap<Integer, Integer>(); public static void main(String[] args) { hm.put(1, 1); final int CEILING_MAX=Integer.parseInt(args[0]); int len=1; int max_count=1; int max_seed=1; for(int i=2; i<CEILING_MAX; i++) { len = seqCount(i); if(len > max_count) { max_count = len; max_seed = i; } } System.out.println(max_seed+"\t"+max_count); } // find the size of the hailstone sequence for N public static int seqCount(int n) { if(hm.get(n) != null) { return hm.get(n); } if(n ==1) { return 1; } else { int length = 1 + seqCount(nextSeq(n)); hm.put(n, length); return length; } } // Find the next element in the sequence public static int nextSeq(int n) { if(n%2 == 0) { return n/2; } else { return n*3+1; } } }

    Read the article

  • Filling combobox from database by using hibernate in Java

    - by denny
    Heyy; I am developing a small swing based application with hibernate in java. And I want fill combobox from database coloumn.How i can do that ? And I don't know in where(under initComponents, buttonActionPerformd) i need to do. For saving i'am using jbutton and it's code is here : private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { int idd=Integer.parseInt(jTextField1.getText()); String name=jTextField2.getText(); String description=jTextField3.getText(); Session session = null; SessionFactory sessionFactory = new Configuration().configure() .buildSessionFactory(); session = sessionFactory.openSession(); Transaction transaction = session.getTransaction(); try { ContactGroup con = new ContactGroup(); con.setId(idd); con.setGroupName(name); con.setGroupDescription(description); transaction.begin(); session.save(con); transaction.commit(); } catch (Exception e) { e.printStackTrace(); } finally{ session.close(); } }

    Read the article

  • Compare only date javascript

    - by moleculezz
    Hi all, I can't seem to figure out what is wrong with my code. Maybe it would be simpler to just compare date and not time. Not sure how to do this either and I searched but couldn't find my exact problem. BTW, when I display the two dates in an alert, they show as exactly the same. My code: window.addEvent('domready', function() { var now = new Date(); var input = $('datum').getValue(); var dateArray = input.split('/'); var userMonth = parseInt(dateArray[1])-1; var userDate = new Date(); userDate.setFullYear(dateArray[2], userMonth, dateArray[0], now.getHours(), now.getMinutes(), now.getSeconds(), now.getMilliseconds()); if(userDate > now) { alert(now+'\n'+userDate); } }); Perhaps there is a simpler way to compare dates and not including the time. Hope someone has an answer... Thanks!

    Read the article

  • Issues with reversing bit shifts that roll over the maximum byte size?

    - by Terri
    I have a string of binary numbers that was originally a regular string and will return to a regular string after some bit manipulation. I'm trying to do a simple caesarian shift on the binary string, and it needs to be reversable. I've done this with this method.. public static String cShift(String ptxt, int addFactor) { String ascii = ""; for (int i = 0; i < ptxt.length(); i+=8) { int character = Integer.parseInt(ptxt.substring(i, i+8), 2); byte sum = (byte) (character + addFactor); ascii += (char)sum; } String returnToBinary = convertToBinary(ascii); return returnToBinary; } This works fine in some cases. However, I think when it rolls over being representable by one byte it's irreversable. On the test string "test!22*F ", with an addFactor of 12, the string becomes irreversible. Why is that and how can I stop it?

    Read the article

  • Why does ANTLR not parse the entire input?

    - by Martin Wiboe
    Hello, I am quite new to ANTLR, so this is likely a simple question. I have defined a simple grammar which is supposed to include arithmetic expressions with numbers and identifiers (strings that start with a letter and continue with one or more letters or numbers.) The grammar looks as follows: grammar while; @lexer::header { package ConFreeG; } @header { package ConFreeG; import ConFreeG.IR.*; } @parser::members { } arith: term | '(' arith ( '-' | '+' | '*' ) arith ')' ; term returns [AExpr a]: NUM { int n = Integer.parseInt($NUM.text); a = new Num(n); } | IDENT { a = new Var($IDENT.text); } ; fragment LOWER : ('a'..'z'); fragment UPPER : ('A'..'Z'); fragment NONNULL : ('1'..'9'); fragment NUMBER : ('0' | NONNULL); IDENT : ( LOWER | UPPER ) ( LOWER | UPPER | NUMBER )*; NUM : '0' | NONNULL NUMBER*; fragment NEWLINE:'\r'? '\n'; WHITESPACE : ( ' ' | '\t' | NEWLINE )+ { $channel=HIDDEN; }; I am using ANTLR v3 with the ANTLR IDE Eclipse plugin. When I parse the expression (8 + a45) using the interpreter, only part of the parse tree is generated: http://imgur.com/iBaEC.png Why does the second term (a45) not get parsed? The same happens if both terms are numbers. Thank you, Martin Wiboe

    Read the article

  • iterate trough each selecter jquery

    - by Sam Vloeberghs
    Hi I'm having problems calculating stuff on my web app. Here is the scenario: I have a html markup like this: <table> <tr> <td><span class="sub_total">10</span></td> </tr> <tr> <td><span class="sub_total">10</span></td> </tr> <tr> <td><span class="sub_total">10</span></td> </tr> </table> <p><span id="total"></span></p> I would like to calculate the main total of all the sub totals: var total; $('.sub_total').each(function(){ total = total + parseInt($(this).text()); }); $('#total').text(total); But I can't get this to work. I get a NaN notification.. Plz help and advice Greeting

    Read the article

  • Vertical crosshair reposition on Google Map after map resize Issue

    - by joe
    I use the following function to add a crosshair to my Google Map. It works great for horizontal resizing. I can not figure out how to make it work for vertical. After resizing the map it requires the user to either zoom in or out 1 layer, upon which the crosshair snaps to center. var crosshairsSize=17; GMap2.prototype.addCrosshairs=function(){ var container=this.getContainer(); if(this.crosshairs){$(this.crosshairs).remove();} var crosshairs=document.createElement("img"); crosshairs.src='../images/crosshair2.gif'; crosshairs.style.width=crosshairsSize+'px'; crosshairs.style.height=crosshairsSize+'px'; crosshairs.style.border='0'; crosshairs.style.position='relative'; crosshairs.style.top=((parseInt(container.clientHeight)-crosshairsSize)/2)+'px'; crosshairs.style.left="0px"; // The map is centered so 0 will do crosshairs.style.zIndex='500'; container.appendChild(crosshairs); this.crosshairs=crosshairs; return crosshairs;}; I use map.checkResize(); and the map is correct, it's just the crosshair that is off. I've tried firing a javascript zoom in one level but it doesn't work like zooming in with the mouse. It's only zooming in/out with the mouse scroll wheel too... clicking and dragging the zoom slider doesn't work so somehow it's liking the mouse scroll wheel. Firing addCrosshairs(); after resize makes no difference. It places the new crosshair in old spot and still requires a mouse scroll zoom.

    Read the article

  • Some jQuery-powered features not working in Chrome

    - by Enchantner
    I'm using a jCarouselLite plugin for creating two image galleries on the main page of my Django-powered site. The code of elements with navigation arrows is generating dynamically like this: $(document).ready(function () { $('[jq\\:corner]').each(function(index, item) { item = $(item); item.corner(item.attr('jq:corner')) }) $('[jq\\:menu]').each(function (index, item) { item = $(item); item.menu(item.attr('jq:menu')) }) $('[jq\\:carousel]').each(function(index, item) { item = $(item); var args = item.attr('jq:carousel').split(/\s+/) lister = item.parent().attr('class') + '_lister' item.parent().append('<div id="'+ lister +'"></div>'); $('#' + lister).append("<a class='nav left' href='#'></a><a class='nav right' href='#'></a>"); toparrow = $(item).position().top + $(item).height() - 50; widtharrow = $(item).width(); $('#' + lister).css({ 'display': 'inline-block', 'z-index': 10, 'position': 'absolute', 'margin-left': '-22px', 'top': toparrow, 'width': widtharrow }) $('#' + lister + ' .nav.right').css({ 'margin-left': $('#' + lister).width() + 22 }) item.jCarouselLite({ btnNext: '#' + lister + ' .nav.right', btnPrev: '#' + lister + ' .nav.left', visible: parseInt(args[0]) }) }) The problem is that if page is loaded through an url, typed in the adress bar, some functions doesn't work and the second gallery appears with the wrong parameters, but if I came to this page via clicking link - everything works perfectly. It happends only in Google Chrome (Ubuntu, stable 5.0.360.0), but not in Firefox or Opera. What could be the reason?

    Read the article

  • int.Parse of "8" fails. int.Parse always requires CultureInfo.InvariantCulture?

    - by Henrik Carlsson
    We develop an established software which works fine on all known computers except one. The problem is to parse strings that begin with "8". It seems like "8" in the beginning of a string is a reserved character. Parsing: int.Parse("8") -> Exception message: Input string was not in a correct format. int.Parse("80") -> 0 int.Parse("88") -> 8 int.Parse("8100") -> 100 CurrentCulture: sv-SE CurrentUICulture: en-US The problem is solved using int.Parse("8", CultureInfo.InvariantCulture). However, it would be nice to know the source of the problem. Question: Why do we get this behaviour of "8" if we don't specify invariant culture? Additional information: I did send a small program to my client achieve the result above: private int ParseInt(string s) { int parsedInt = -1000; try { parsedInt = int.Parse(s); textBoxMessage.Text = "Success: " + parsedInt; } catch (Exception ex) { textBoxMessage.Text = string.Format("Error parsing string: '{0}'", s) + Environment.NewLine + "Exception message: " + ex.Message; } textBoxMessage.Text += Environment.NewLine + Environment.NewLine + "CurrentCulture: " + Thread.CurrentThread.CurrentCulture.Name + "\r\n" + "CurrentUICulture: " + Thread.CurrentThread.CurrentUICulture.Name + "\r\n"; return parsedInt; }

    Read the article

  • If statement is ignored

    - by user2898120
    I am making a simple matchmaker as a learning project in JAVA. My program so far just asks a few questions, but I wanted to do gender specific questions, so I asked for their sex (m or f) and then attempted to add a message that only showed if sex was m. The dialog should say "well done, you are male!". Else it restarts method. Every time, no matter what I type it restarts the program. Here is my code: import javax.swing.JOptionPane; public class Main { public static void main(String[] args){ setVars(); } public static void setVars(){ String name = JOptionPane.showInputDialog(null, "What is your name?"); String sAge = JOptionPane.showInputDialog(null, "What is your age?"); String sex = JOptionPane.showInputDialog(null, "What is your sex?\n(Enter m or f)"); if (sex == "m"){ JOptionPane.showMessageDialog(null, "Well done, you are male.\nKeep Going!"); } int age = Integer.parseInt(sAge); String chars = JOptionPane.showInputDialog(null, "Name three charectaristics"); } }

    Read the article

  • Can't add object to Array in jQuery's getJSON data function (scope issue)

    - by seo20
    I have a person object and wants to store it into a global ArrayCollection I have made. Works great in normal scope: var s = new ArrayCollection(); s.add(new person("Knud", "Mikkelsen", 35)); The problem is when I want to add people inside my jQuery function "mainFunction". I can't seem to get it right. I know it's something to do with scope and I have to wrap something in functions like in my ArrayCollection. Please help me - thanks a lot. function ArrayCollection() { var myArray = new Array; return { empty: function () { myArray.splice(0, myArray.length); }, add: function (myElement) { myArray.push(myElement); }, getAll: function () { return myArray; } } } function person(firstName, lastName, age) { this.firstName = firstName; this.lastName = lastName; this.age = parseInt(parseFloat(age)); } function mainFunction() { //.... var s = new ArrayCollection(); s.add(new person("Knud", "Mikkelsen", 35)); $.getJSON(url, function (data) { for (var x = 0; x < data.length; x++) { var myPerson = new person(data[x].FirstName.toString(), data[x].LastName.toString(), data[x].Age.toString()); s.add(myPerson); } }); alert(drawArray(s.getAll())); } function drawArray(myArray) { var v = ""; for (var i = 0; i < myArray.length; i++) { v += myArray[i].firstName + " " + myArray[i].lastName + " (" + myArray[i].age + ")\n"; } return v; }

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >