java - ActionBean is always null on page load -


I am using strips to create a small Java application. I am able to post back to my ActionBeans, but $ (verb == empty) on page load is always correct, to reduce potential issues, I'm using Hello Hello World program I am here.

My Action:

  Package Stripbook. Action; Import java.util.Date; Import java.util.Random; Import net.sourceforge.stripes.action.ActionBean; Import net.sourceforge.stripes.action.ActionBeanContext; Import net.sourceforge.stripes.action.DefaultHandler; Import net.sourceforge.stripes.action.ForwardResolution; Import net.sourceforge.stripes.action.Resolution; Public class Hello implementation of ActionBean ActionBean {/ * (1) * / Private ActionBean Contact CTX; Public actionben contact getContext () {return CTX; } Public Zero Setcontext (Action Bean Contex CTX) {this.ctx = ctx; } Private Dead Date; / * (2) * / Public Debt Mill () {Date of Return; } @ Default handler public resolution current date () {/ * (3) * / date = new date (); Return to the new Forward Resolutions (see); } Public resolution randomDate () {long max = System.currentTimeMillis (); Long Random = New Random () NextLong ()% max; Date = new date (random); Return to the new Forward Resolutions (see); } Private Static Last String VIEW = "/hello.jsp"; }   

and my jsp page:

  & lt;% @ page content type = "text / html; charset = ISO-885 9-1" Language = "java"%> & Lt;% @ taglib prefix = "s" uri = "http://stripes.sourceforge.net/stripes.tld"% & gt; & Lt;% @ taglib prefix = "FMT" ury = "http://java.sun.com/jsp/jstl/fmt"% & gt; & Lt ;! DOCTYPE HTML PUBLIC "- // W3C // DTD HTML 4.01 // N" "http://www.w3.org/TR/html4/strict.dtd"> & Lt; Html & gt; & Lt; Top & gt; & Lt; Title & gt; Hello, Stripes! & Lt; / Title & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; H3 & gt; Hello, Stripes! & Lt; / H3 & gt; & Lt; P & gt; Date and time: & lt; Br> & Lt; P & gt; & Lt; P & gt; $ {ActionBean == faucet} & lt; / P & gt; & Lt; Fmt: formatDate type = "both" dateStyle = "full" value = "$ {actionBean.date}" /> & Lt; / P & gt; & Lt; / P & gt; & Lt; P & gt; & Lt; S: link beanclass = "stripesbook.action.HelloActionBean" event = "currentDate" & gt; Show current date and time & lt; / S: link & gt; | & Lt; S: link beanclass = "stripesbook.action.HelloActionBean" event = "random date" & gt; Show random date and time & lt; / S: link & gt; & Lt; / P & gt; & Lt; / Body & gt; & Lt; / Html & gt;   

When I set a breakpoint in the actionben, they do not slip on the page load, so it seems that the compulsion is not happening like that. I am using NetBens for Apache / Comet. This is probably a simple solution but there are relatively few documents on strips outside official documents.

You need to declare this to be a bean to use.

Enter into:

  & lt; Jsp: useBean id = "actionBean" class = "stripesbook action.HelloActionBean" />   

At the top of your JSP like this:

  & lt;% @ page content type = "text / html; charset = ISO-885 9 -1 "language =" Java "%> & Lt;% @ taglib prefix = "s" uri = "http://stripes.sourceforge.net/stripes.tld"% & gt; & Lt;% @ taglib prefix = "FMT" ury = "http://java.sun.com/jsp/jstl/fmt"% & gt; & Lt; Jsp: useBean id = "actionbene" class = "stripesbook. Action. Halo actionben" / & gt; & Lt ;! DOCTYPE HTML PUBLIC "- // W3C // DTD HTML 4.01 // N" "http://www.w3.org/TR/html4/strict.dtd">    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -