Search Results

Search found 148 results on 6 pages for 'jstl'.

Page 3/6 | < Previous Page | 1 2 3 4 5 6  | Next Page >

  • Pass first element of jsp list to javascript

    - by Lucian Enache
    Ok so I'm trying to access the first element of a JSP list, here's what I've come up with so far without any kind of luck: onclick="alert('<%=list[0]%>');" What's the best approach to access the first element and eventually to pass it to a javascript variable/function ? I've heard that the <% %> tags are deprecated and some are suggesting relaying on JSTL/EL how can one use those without having to iterate the entire list and put a breakpoint for the iterators ?

    Read the article

  • Yet another bug of JSF?

    - by Nitesh Panchal
    Hello, Again i see that the @PostConstruct is firing every time even though no binding attribute is used. See this code :- <?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:ui="http://java.sun.com/jsf/facelets" xmlns:c="http://java.sun.com/jsp/jstl/core"> <h:head> <title>Facelet Title</title> </h:head> <h:body> <h:form> <c:forEach var="item" items="#{TestBean.listItems}"> <h:outputText value="#{item}"/> </c:forEach> <h:commandButton value="Click" actionListener="#{TestBean.actionListener}"/> </h:form> </h:body> </html> And this is the simplest possible bean in JSF :- package managedBeans; import java.io.Serializable; import java.util.ArrayList; import java.util.List; import javax.annotation.PostConstruct; import javax.faces.bean.ManagedBean; import javax.faces.bean.ViewScoped; @ManagedBean(name="TestBean") @ViewScoped public class TestBean implements Serializable { private List<String> listItems; public List<String> getListItems() { return listItems; } public void setListItems(List<String> listItems) { this.listItems = listItems; } public TestBean() { } @PostConstruct public void init(){ System.out.println("Post Construct fired!"); listItems = new ArrayList<String>(); listItems.add("Mango"); listItems.add("Apple"); listItems.add("Banana"); } public void actionListener(){ System.out.println("Action Listener fired!"); } } Do you see any behaviour that should cause postconstruct callback to fire each time? I think JSF 2.0 is highly unstable. If it has to fire PostConstruct each and every time what purpose does @ViewScoped serve. Why not to use @RequestScoped only? I thought i have made some mistake in my application. But when i created this simplest possible in JSF, i still get this error. Am i not understanding the scopes of JSF? or are they not testing it properly? Further, if you remove c:forEach and replace it with ui:repeat, then it works fine. Waiting for replies to confirm whether it is bug or it is intentional to stop the programmers from using jstl?

    Read the article

  • Checking attribute exists in JSP

    - by Javi
    Hello, I have some classes which extends a superclass, and in the JSP I want to show some attributes of these classes. I only want to make one JSP, but I don't know in advance if the object has an attribute or not. So I need a JSTL expression or a tag which checks that the object I pass has this attribute (similar to in operator in javascript, but in the server). <c:if test="${an expression which checks if myAttribute exists in myObject}"> <!-- Display this only when myObject has the atttribute "myAttribute" --> <!-- Now I can access safely to "myAttribute" --> ${myObject.myAttribute} </C:if> How can I get this? Thanks.

    Read the article

  • how to submit a form without losing values already selected at the same form

    - by kawtousse
    Hi everyone, I am using jstl with dropdown lists. When i click submit button i success the specification but values int dropdownlists are reinitialized. So I want to submit form without loosing the values already selected in the form because I need to stay always at the same level in the form.To be more clear, user choose a value from ddl and click edit button to show other options and fill them at the same form without loosing what he has selected. I have tried to deal like that... <form action="myjsp.jsp" method="post"> <input type="Submit" value="Edit"> ...but it doesn't work. Thank you for your help.

    Read the article

  • Jsp cache problem

    - by idiotgenius
    I use javascript and css to build a multi-level drop down menu with following markups: <ul> <li>menu item 1</li> <ul> <li><a href="#">sub menu menu item 1</a></li> ................. This markup is generated by a custom JSTL tag <mui:menu .../> which loads menu data from a database. I hope my jsp page can behave like this: if menu data has not changed since last time I visited the page, just use browser's cache otherwise load from database... How can I do it? I don't know much detail about cache mechanism.

    Read the article

  • How to use <c:out value=...> taglib

    - by artaxerxe
    I have the class A: package a; public class A { private int x = 9; public int getX() { return x; } } and the ajsp.jsp file: <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body> <jsp:useBean id = "a" class = "a.A" /> <c:out value = "${a.x}" /> </body> </html> when i run it, it gives an error : org.apache.jasper.JasperException: /ajsp.jsp(11,0) PWC6236: According to TLD or attribute directive in tag file, attribute value does not accept any expressions if instead of <c:out value = "${a.x}" /> i use <jsp:getProperty property="x" name="a"/> it goes perfect. So, what is the problem? Thank advance.

    Read the article

  • JSP request parameter is returning null on a jsp include with Weblogic.

    - by doug
    Hello, I am having trouble with the jsp:include tag. I have code like the following: <jsp:include page="./Address.jsp"> <jsp:param value="30" name="tabIndex"/> <jsp:param value="true" name="showBox"/> <jsp:param value="none" name="display"/> </jsp:include> The page is included fine, but when I try to access the parameters on the Address.jsp page, they are null. I have tried accessing them the following ways (with jstl): <c:out value="${param.tabIndex}" /> <c:out value="${param['tabIndex']} /> <%= request.getParameter("tabIndex") %> <c:out value="${pageScope.param.tabIndex} /> ${param.tabIndex} etc... Here is the kicker, The above works fine in tomcat 5.5. However, when I deploy the application in Weblogic 10, it does not. Also, the code works fine in other areas of my application (on weblogic) just not a particular page. Any Ideas? Thanks!

    Read the article

  • JSP request parameter is returning null on a jsp include win Weblogic.

    - by doug
    Hello, I am having trouble with the jsp:include tag. I have code like the following: <jsp:include page="./Address.jsp"> <jsp:param value="30" name="tabIndex"/> <jsp:param value="true" name="showBox"/> <jsp:param value="none" name="display"/> </jsp:include> The page is included fine, but when I try to access the parameters on the Address.jsp page, they are null. I have tried accessing them the following ways (with jstl): <c:out value="${param.tabIndex}" /> <c:out value="${param['tabIndex']} /> <%= request.getParameter("tabIndex") %> <c:out value="${pageScope.param.tabIndex} /> ${param.tabIndex} etc... Here is the kicker, The above works fine in tomcat 5.5. However, when I deploy the application in Weblogic 10, it does not. Also, the code works fine in other areas of my application (on weblogic) just not a particular page. Any Ideas? Thanks!

    Read the article

  • Set request attributes when a Form is POSTed

    - by ssahmed555
    Is there any way to set request attributes (not parameters) when a form is posted? The problem I am trying to solve is: I have a JSP page displaying some data in a couple of dropdown lists. When the form is posted, my Controller servlet processes this request (based on the parameters set/specified in the form) and redirects to the same JSP page that is supposed to display addition details. I now want to display the same/earlier data in the dropdown lists without having to recompute or recalculate to get that same data. And in the said JSP page, the dropdown lists in the form are populated by data that is specified through request attributes. Right now, after the Form is POSTed and I am redirected to the same JSP page the dropdown lists are empty because the necessary request attributes are not present. I am quite the n00b when it comes to web apps, so an obvious & easy solution to this problem escapes me at the moment! I am open to suggestions on how to restructure the control flow in the Servlet. Some details about this app: standard Servlet + JSP, JSTL, running in Apache Tomcat 6.0. Thanks.

    Read the article

  • Item value in JSTL foreach loop not working in Portlet

    - by danimajo
    Given the following Portlet Code: ArrayList nameList = new ArrayList(); nameList.add("Willi Willisch"); nameList.add("Seppi Seppisch"); renderRequest.setAttribute("names", nameList); And the following JSP Code: <c:forEach var="aName" items="${names}"> <tr> <td>${aName} </td> </tr> </c:forEach> Prints out: ${aName} ${aName} I don't have any clue why a $(aName) isn't evaluated. The forEach loops works, because ${aName} is printed out twice ....

    Read the article

  • select and jstl query

    - by sarah
    Hi All, I am displaying data in combo box using ${role} the requirement is on clcik of edit i want to show the preselected value in the drop down ,suppose i have cat,rat and i selected rat and i saved it in database ,now when i want to edit the details i want to show rat first in drop down as pre selected and then cat,how to od this ?

    Read the article

  • JSTL expression evaluation from a string

    - by Venkatesh
    Is it possible to evaluate a String as EL expression in JSP and get value from it? I need an expression like ${model.${fieldPath}} where fieldPath will contain the required object path from a nested object model. I can get the actual field path by using but I am not sure how to evaluate a string and get the value from it Any help regarding this would be highly appreciated.

    Read the article

  • issue of JSTL forEach iterate from arrayList

    - by Mickey
    In my code, I have used ArrayList which stores the number format like '$0.00 to $1,000,000.00' in each index of array list. while iterate in JSP through tag, its values are printing like $0.00 to $1 as a first string, 000 as a second string and 000.00 as a thrid string. but it has to print like '$0.00 to $1,000,000.00'. what will be the problem is? Thanks in advance

    Read the article

  • invoke javax.el.MethodExpression from jsf component

    - by marcos
    Hello gurus I have a jsp tag wich takes a javax.el.MethodExpression as attribute: <%@ attribute name="action" required="true" type="javax.el.MethodExpression" rtexprvalue="true" %> within the same tag i have: <h:commandLink action="#{action}"> link text </h:commandLink> I'm getting the following error when i try to click the link: javax.faces.FacesException: #{action}: org.apache.jasper.el.JspMethodNotFoundException: /WEB-INF/tags/pager/pager.tag(17,1) '#{action}' Identity 'action' was null and was unable to invoke is it possible for the commandLink to properly invoke the "action" method?

    Read the article

  • Populating JavaScript Array from JSP List

    - by tkeE2036
    Ok so perhaps someone can help me with a problem I'm trying to solve. Essentially I have a JSP page which gets a list of Country objects (from the method referenceData() from a Spring Portlet SimpleFormController, not entirely relevant but just mentioning in case it is). Each Country object has a Set of province objects and each province and country have a name field: public class Country { private String name; private Set<Province> provinces; //Getters and setters } public class Province { private String name; //Getters and setters } Now I have two drop down menus in my JSP for countries and provinces and I want to filter the provinces by country. I've been following this tutorial/guide to make a chain select in JavaScript. Now I need a dynamic way to create the JavaScript array from my content. And before anyone mentions AJAX this is out of the question since our project uses portlets and we'd like to stay away from using frameworks like DWR or creating a servlet. Here is the JavaScript/JSP I have so far but it is not populating the Array with anything: var countries = new Array(); <c:forEach items="${countryList}" var="country" varStatus="status"> countries[status.index] = new Array(); countries[status.index]['country'] = ${country.name}; countries[status.index]['provinces'] = [ <c:forEach items="${country.provinces}" var="province" varStatus="provinceStatus"> '${province.name}' <c:if test="${!provinceStatus.last}"> , </c:if> </c:forEach> ]; </c:forEach> Does anyone know how to create an JavaScript array in JSP in the case above or what the 'best-practice' would be considered in this case? Thanks in advance!

    Read the article

  • Populate JSP dropdown with database info

    - by Cano63
    I'm looking for the way to populate a JSP dropdown. I want that when the JSP loads it fills the dropdown with the info that I have in a database table. I'm including the code of my class that will create the array and fill it with the database info. What I don't know is how to call that class from my JSP and fill the dropdown. // this will create my array public static ArrayList<DropDownBrands> getBrandsMakes() { ArrayList<DropDownBrands> arrayBrandsMake = new ArrayList<DropDownBrands>(); while (rs.next()) { arrayBrandsMake.add(loadOB(rs)); // CARGO MI ARREGLO CON UN OBJETO } return arrayBrandsMake; } // this will load my array object private static DropDownBrands loadOB(ResultSet rs) throws SQLException { DropDownBrands OB = new DropDownBrands(); OB.setBrands("BRAN"); return OB; }

    Read the article

  • Which option do you like the most?

    - by spderosso
    I need to show a list of movies ordered by the date they were registered in the system and the amount of comments users have made about them. E.g: Title | Register Date | # of comments Gladiator | 02-01-2010 | 30 Matrix | 01-02-2010 | 20 It is a web application that follows MVC. So, I have the object "Movie", there is a MovieManager interface that is used for retrieving/persisting data to the database and a servlet RecentlyAddedMovies.java that forwards to a .jsp to render the list. I will explain my problem by showing an example of how I am doing another similar task: Showing top ranked movies. Regarding the MovieManager: /** * Returns a collection of the x best-ranked movies * @param x the amount of movies to return * @return A collection of movies * @throws SQLException */ public Collection<Movie> getTopX(int x) throws SQLException; The servlet: public class Top5 extends HttpServlet{ @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { MovieManager movManager = JDBCMovieManager.getInstance(); try { req.setAttribute("movies", movManager.getTopX(5)); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } req.getRequestDispatcher("listMovies.jsp").forward(req, resp); } } And the listMovies.jsp has is some place something like: <c:forEach var="movie" items="${movies}"> ... <c:out value="${movie.title}"/> ... </c:forEach> The difference between the top5 problem and the problem I am trying to solve is that with the top5 thing all the data I needed to show in the view where part of the "Movie" object, so the MovieManager simply returned a Collection of Movies. Now, the MovieManager must retrieve an ordered list of (Movie, # of comments). The Movie object has a collection of Comment associated but of course, it lacks an instance variable with the length of that collection. The following things came into my mind: a) Create a MovieView object or something like that, that is only used by the "View" and "Controller" layer of the MVC which is not part of the "Model" in the sense that is used only for easy retrieval and display of information. This MovieView object will have a title, registerDate and # of Comments so the thing would look something like this: /** * Returns a collection of the x most recently added movies * @param x the amount of movies to return * @return A collection of movies * @throws SQLException */ public Collection<Movie2> getXRecentlyAddedMovies(int x) throws SQLException; The .jsp: <c:forEach var="movie2" items="${movies2}"> ... <c:out value="${movie2.title}"/> <c:out value="${movie2.registerDate}"/> <c:out value="${movie2.noOfComments}"/> ... </c:forEach> b) Add to the Collection the movie has, empty Comments (there is no actual need to retrieve all the comment data from the database) so that the comment's collection.size() will show the number of comments that movie has. (This sounds horrible to me) c) Add to the "Movie" object an instance field noOfComments with the setter and getter that will help with this type of cases even if, looking only from the object point of view, it is a redundant field since it already has a Collection that is ".size()"able . d) Make the MovieManager retrieve some structure like a Map or a Collection of a two component array or something like that that will contain both a Movie object and the associated number of comments and with JSLT iterate over it and show it accordingly.

    Read the article

  • c:forEach.items getting repetitively called

    - by Joshua
    Environment: Seam, Richfaces The following code snippet causes the method getUsers to be called multiple times, how do I avoid this in my application so that it gets called only once. <c:forEach items="#{userHome.getUsers()}" var="_user"> </c:forEach>

    Read the article

  • How to find the parent element using javascript

    - by Kalpana
    I want to change the background color of the table cell when radio button inside the cell is clicked. <table> <tr> <c:forEach items="#{books}" var="book"> <td align="center"> <h:selectOneRadio value="#{book.price}" onclick="this.parentElement.style.background-color='red';"> <f:selectItems value="#{books.getDetails()}" /> </h:selectOneRadio> </td> </c:forEach> </tr> </table> How to get the parent element reference.

    Read the article

  • How to comment in jspx page

    - by ricky
    How to comment the code in jspx page? I have tried several methods, <%-- --, but it doesn't not work! So I have to: code, it is really urgly, Is there any other ways? Any help is appreciated!

    Read the article

  • How to add next and previous buttons to my pager row

    - by eddy
    Hi folks!! How would I add next/previous buttons to this snippet, cause as you can see ,it will display as many links as it needs, so if you have a high number of pages then this might not be the best solution <c:choose> <c:when test="${pages >1}"> <div class="pagination art-hiddenfield" > <c:forEach var="i" begin="1"end="${pages}" step="1"> <c:url value="MaintenanceListVehicles.htm" var="url"> <c:param name="current" value="${i}"/> </c:url> <c:if test="${i==current}"> <a href="<c:out value="${url}"/> " class="current" > <c:out value="${i}" /></a> </c:if> <c:if test="${i!=current}"> <a href="<c:out value="${url}"/> " > <c:out value="${i}" /></a> </c:if> </c:forEach> </div> </c:when> <c:otherwise> <div align="center"> </div> </c:otherwise> </c:choose> CSS: .pagination .current { background: #26B; border: 1px solid #226EAD; color: white; } .pagination a { display: block; border: 1px solid #226EAD; color: #15B; text-decoration: none; float: left; margin-bottom: 5px; margin-right: 5px; padding: 0.3em 0.5em; } .pagination { font-size: 80%; float: right; } div { display: block; } This is what I get with my current code: And this is what I'd like to display, with ellipsis if possible Hope you can help me out.

    Read the article

< Previous Page | 1 2 3 4 5 6  | Next Page >