Announcement Announcement Module
Collapse
No announcement yet.
Display tags in the Spring Applications Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Display tags in the Spring Applications

    Hi If any one has used the Display Tags with Spring .
    Please help me ..
    I am populating data in the form of HashMap as a Model.
    How can I populate data in the Display Tags.


    My Code for Data is :--

    public class InventoryController implements Controller {
    protected final Log logger=LogFactory.getLog(getClass());
    private ProductManagerService productManager;

    public void setProductManager(ProductManagerService productManager) {
    this.productManager = productManager;
    }
    public ModelAndView handleRequest(HttpServletRequest Request,HttpServletResponse response)throws ServletException,IOException
    { String now=(new Date().toString());
    logger.info("Returning hello view"+now);
    Map myModel = new HashMap();
    myModel.put("now", now);
    myModel.put("products", this.productManager.getProducts());
    return new ModelAndView("hello", "model", myModel);
    }
    }


    For Displayig data i have code as :--

    <h3>Products</h3>
    <h2>Display Tag Start</h2>

    <display:table name="products">
    <display:column property="description" /><c:out value="${model.products.description}"/>
    <display:column property="price"/><c:out value="${model.products.price}"/>
    </display:table>

    <h2>Display tag end </h2>

  • #2
    [ code][/code ] tags next time please.

    I suggest you recheck the way Display Tag works.

    1) Your definition is wrong, don't include the c:out stuff
    2) the table name should be model.products

    Code:
    <display:table name="model.products">
      <display:column property="description" />
      <display:column property="price"/>
    </display:table>

    Comment


    • #3
      Display tags in the Spring Application

      thanks a lot for Reply Marten,

      I tried with your suggestions, but it is not populating the data. Can you tell me if the data which i is being returned ias Hasmap and in the Display tag in the name attribute we have to provide the collection.

      In my program can you suggest , where i need to furthur change

      Thanks in advance martin

      Comment


      • #4
        What does productManager.getProducts() return? See if you have data populating into the model.

        Are you getting "Nothing found to display" message on your jsp or nothing at all?

        Comment


        • #5
          Collection to iterate for the Display tag

          Hello thanks for the reply,

          I am geting the data from this productManager.getProducts()
          in the form of hashMap.

          I understand in the display tags we have to give the name of the colllection but it is not taking up..

          Plz suggest me.

          Comment


          • #6
            What does your HashMap look like? What is the key & the value?

            Comment


            • #7
              Display tags in the Spring Application

              Hi,I have got the display tags work in my system, it is populating the data but when i click on the pgination (i.e next or previous) or I try downloading it is showing error as resource not found.

              <h2>Display Tag Start</h2>

              <c:set var="prod" value="${model.products}" scope="request"/>
              <display:table name="prod" export="true" pagesize="1">
              <display:column property="id" sortable="true"/>
              <display:column property="description" />
              <display:column property="price"/>
              </display:table>
              <h2>Display tag end </h2>

              Comment

              Working...
              X