Re: from Action to PageContext: how's it done?
ServletContext attributes 'foo' #application['foo'] or #application.foo Access to PageContext for attribute foo #attr['foo'] or #attr.foo in WebWork 1.x one could access special named objects (the request scope attributes to be exact) by using "@foo", but now special variables are accessed using "#foo" is merely a request to another object in the OgnlContext http://struts.apache.org/2.0.11.1/docs/ognl-basics.html Good Stuff Martin - Original Message - From: "Adam Hardy" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" Sent: Saturday, April 19, 2008 9:11 PM Subject: Re: from Action to PageContext: how's it done? > Dave Newton on 20/04/08 00:23, wrote: > > --- Adam Hardy <[EMAIL PROTECTED]> wrote: > >> So you say the StrutsRequestWrapper holds the struts context [...] > > > > No, I'm saying it has access to it via ActionContext.getContext(). > > > >> and is accessed somewhere in the Result to pull everything down > >> into the PageContext? > > > > I'm not sure what that means. > > > > All the request wrapper does (slightly simplified) is call super.getAttribute > > (where super is an HttpServletRequestWrapper). If nothing is returned from > > that, as would be the case with a typical action and action property, then > > the wrapper will query the stack for the value. > > > > You should probably just look at the source code, no? > > Yes, I guess I should if I had a team of sherpas for the expedition. I once > scaled the face of the Hibernate Source Massif and only 3 of the team came back > alive. > > But seriously, I appreciate your comments a lot since they buy me out of lot of > hard source code reading, which is not something too pleasant when you don't > know where you're aiming for, as you probably know. > > What you're saying is clear except one thing - in JSTL I can access the action. > And in JSTL, I'm not calling request.getAttribute() - I'm _not_ doing this: > > ${requestScope['myObject']} > > I'm just doing this: > > ${myObject} > > and struts somehow gives me the right info, which to my mind means that Struts > has put that object into the PageContext already. > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: from Action to PageContext: how's it done?
--- Adam Hardy <[EMAIL PROTECTED]> wrote: > What you're saying is clear except one thing - in JSTL I can access the > action. And in JSTL, I'm not calling request.getAttribute() - I'm _not_ doing this: > > ${requestScope['myObject']} > > I'm just doing this: > > ${myObject} > > and struts somehow gives me the right info, which to my mind means that > Struts has put that object into the PageContext already. I told you precisely what it did: if the request wrapper can't find the attribute in normal scope, it goes to the stack. Here is the entire relevant source; it's 36 lines. With comments. public Object getAttribute(String s) { if (s != null && s.startsWith("javax.servlet")) { // don't bother with the standard javax.servlet attributes, we can short-circuit this // see WW-953 and the forums post linked in that issue for more info return super.getAttribute(s); } ActionContext ctx = ActionContext.getContext(); Object attribute = super.getAttribute(s); if (ctx != null) { if (attribute == null) { boolean alreadyIn = false; Boolean b = (Boolean) ctx.get("__requestWrapper.getAttribute"); if (b != null) { alreadyIn = b.booleanValue(); } // note: we don't let # come through or else a request for // #attr.foo or #request.foo could cause an endless loop if (!alreadyIn && s.indexOf("#") == -1) { try { // If not found, then try the ValueStack ctx.put("__requestWrapper.getAttribute", Boolean.TRUE); ValueStack stack = ctx.getValueStack(); if (stack != null) { attribute = stack.findValue(s); } } finally { ctx.put("__requestWrapper.getAttribute", Boolean.FALSE); } } } } return attribute; } Dave - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: from Action to PageContext: how's it done?
Dave Newton on 20/04/08 00:23, wrote: --- Adam Hardy <[EMAIL PROTECTED]> wrote: So you say the StrutsRequestWrapper holds the struts context [...] No, I'm saying it has access to it via ActionContext.getContext(). and is accessed somewhere in the Result to pull everything down into the PageContext? I'm not sure what that means. All the request wrapper does (slightly simplified) is call super.getAttribute (where super is an HttpServletRequestWrapper). If nothing is returned from that, as would be the case with a typical action and action property, then the wrapper will query the stack for the value. You should probably just look at the source code, no? Yes, I guess I should if I had a team of sherpas for the expedition. I once scaled the face of the Hibernate Source Massif and only 3 of the team came back alive. But seriously, I appreciate your comments a lot since they buy me out of lot of hard source code reading, which is not something too pleasant when you don't know where you're aiming for, as you probably know. What you're saying is clear except one thing - in JSTL I can access the action. And in JSTL, I'm not calling request.getAttribute() - I'm _not_ doing this: ${requestScope['myObject']} I'm just doing this: ${myObject} and struts somehow gives me the right info, which to my mind means that Struts has put that object into the PageContext already. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: from Action to PageContext: how's it done?
--- Adam Hardy <[EMAIL PROTECTED]> wrote: > So you say the StrutsRequestWrapper holds the struts context [...] No, I'm saying it has access to it via ActionContext.getContext(). > and is accessed somewhere in the Result to pull everything down > into the PageContext? I'm not sure what that means. All the request wrapper does (slightly simplified) is call super.getAttribute (where super is an HttpServletRequestWrapper). If nothing is returned from that, as would be the case with a typical action and action property, then the wrapper will query the stack for the value. You should probably just look at the source code, no? Dave - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: from Action to PageContext: how's it done?
Dave Newton on 19/04/08 23:54, wrote: --- Adam Hardy <[EMAIL PROTECTED]> wrote: The struts interceptors encompass both the actions and the results, but how does struts put the action properties into the pageContext? It doesn't; it puts the action on the stack. The tags use OGNL to get values from the stack context, or when using JSP 2.0 EL the S2 request wrapper will go to the stack if the value isn't found in the normal contexts. I guess I'm not really sure what you're asking. I think you've understood what I'm asking. So how does the stack context get put into the pageContext? The pageContext only comes into existence when the JSP is called via (presumably) a RequestDispatcher.forward() - what I can't figure out is how struts gets involved in the JSP when I'm not using struts tags there or anything except some JSTL to ask for an action property such as "${myPropertyOnAction}" So you say the StrutsRequestWrapper holds the struts context and is accessed somewhere in the Result to pull everything down into the PageContext? I don't understand the javadoc for StrutsRequestWrapper which says "All Struts requests are wrapped with this class, which provides simple JSTL accessibility. This is because JSTL works with request attributes, so this class delegates to the value stack " JSTL only works with request attributes when you explicitly say "${requestScope[thing]}" No? Adam - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: from Action to PageContext: how's it done?
--- Adam Hardy <[EMAIL PROTECTED]> wrote: > The struts interceptors encompass both the actions and the results, but how > does struts put the action properties into the pageContext? It doesn't; it puts the action on the stack. The tags use OGNL to get values from the stack context, or when using JSP 2.0 EL the S2 request wrapper will go to the stack if the value isn't found in the normal contexts. I guess I'm not really sure what you're asking. Dave - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: from Action to PageContext: how's it done?
Ralf Fischer on 19/04/08 18:43, wrote: On Sat, Apr 19, 2008 at 7:29 PM, Adam Hardy <[EMAIL PROTECTED]> wrote: From looking at the struts2 architecture, one of the big questions that I can't find the answer to is how struts/xwork moves objects such as the properties on an action into the PageContext. Actually it's not done at all. I guess your real question is "I create some objects in my action and want to render them somehow in the view. How do I do that?" Sorry, your guess was wide of the mark. My mistake for not being more explicit. I am familiar enough with the struts framework to know how I can put getters and setters on my action and use properties accordingly in my JSP with JSTL or OGNL or whatever, but my question is one meta-level up from your answer, i.e. how is that done by struts? The struts interceptors encompass both the actions and the results, but how does struts put the action properties into the pageContext? Adam - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Scope Interceptor
Hi konference I read the article there: http://struts.apache.org/2.0.9/docs/scope-interceptor.html and a want use scope interceptor, but it not work my. I dont know exactly, that i good understand it. I want save into session model: Employee. // In my Action Class I have this code: --- public class TestScope extends ActionSupport implements ModelDriven { private Employee emp = new Employee(new Integer(10), "tomas", "jurman"); public Employee getModel() { return emp; } public void setModel(Employee model) { this.emp = model; } } //### in struts.xml I have this part of code: note: instead tag param i give here tag para because it dont show it - model true start /jsp/start.jsp //# in JSP i read the session: //### Thanks for help very much Tomas Jurman Czech Republic - Tomas Jurman Czech Republic -- View this message in context: http://www.nabble.com/Scope-Interceptor-tp16787023p16787023.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: from Action to PageContext: how's it done?
Hello Adam On Sat, Apr 19, 2008 at 7:29 PM, Adam Hardy <[EMAIL PROTECTED]> wrote: > From looking at the struts2 architecture, one of the big questions that I > can't find the answer to is how struts/xwork moves objects such as the > properties on an action into the PageContext. Actually it's not done at all. I guess your real question is "I create some objects in my action and want to render them somehow in the view. How do I do that?" Upon request to your struts web application the filter creates a value stack which holds all the information needed. The action responsible for the "page" of I may say so is put onto the stack and the single interceptors on the stack set the parameters from the configuration or the requested URI into the stack. Usually this leads to the population of action properties if you did everything right, meaning the URI parameter ?foo=1 will lead to a call of setFoo("1"). The same stack is still available when the result associated with the action is rendered, which may be a JSP page, and you can access information easily by using OGNL expressions to extract the information you need. > When an interceptor is executing for example, calling > ServletActionContext.getPageContext() will return null until the action has > been invoked. Is there a page context yet when you are some method calls away from a servlet filter? > Invoking the action also executes the Result, so the JSP is called and the > PageContext is created. > > But how does struts do that? I've got a feeling my knowledge of the Servlet > Container could be better :( I suggest some basic reading on struts, here[1] for example. Cheers, -Ralf [1] http://struts.apache.org/2.0.11.1/docs/home.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: s2 in tomcats shared lib/
Well it depends if you are ALWAYS developing using the same library versions or not. Be aware that Struts level of compatibility changes from version to version: For example, from 2.09 to 2.0.11 imposes several constraints in its tag library, so you may want to prevent this to be in a common place. However regarding Spring, upgrades from v2.0.x to v.2.0.y are drop in replacements, so it would not hurt (in theory at least) 2008/4/19, Marc Ende <[EMAIL PROTECTED]>: > Hi, > > a few years ago everyone told that's not good to have the sturts.jar's in a > shared location in a tomcat-instance. > What about now (struts 2)? > I'm asking because I've got several webapps which belongs together and most > of them are build using struts 2 and > spring. After assembling the war (directory or file) I've seen that the huge > size (between 12 to 17mb) of the webapps is > related to the number of deployed jars. So I'd like to clean up a little and > put some of the commonly used > jars in the ${catalina.home}/lib folder. What about the new s2-jar's? Do I > ran into trouble when I'm putting it into the > global lib-folder or do I get (not-wanted) side-effects from deploying them > into this location? > > Thanks for your help! > > Marc > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
from Action to PageContext: how's it done?
From looking at the struts2 architecture, one of the big questions that I can't find the answer to is how struts/xwork moves objects such as the properties on an action into the PageContext. When an interceptor is executing for example, calling ServletActionContext.getPageContext() will return null until the action has been invoked. Invoking the action also executes the Result, so the JSP is called and the PageContext is created. But how does struts do that? I've got a feeling my knowledge of the Servlet Container could be better :( Thanks for any info, regards Adam - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Declarative validation: show colored message
Hi, how can I show up a colored message when doing declarative validation via xml file. I tried to surround the message text by a div, but then the messages werent shown any longer: >>> You must enter your fistname. <<< Therefore, I dont know how to color that output string. Can anyone help me? Thanks and best regards Peter - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: result in different pages
you can store in session and retrieve later using http://struts.apache.org/2.0.11.1/docs/ognl-basics.html - Original Message - From: <[EMAIL PROTECTED]> To: "struts mailing list" Sent: Saturday, April 19, 2008 7:24 AM Subject: result in different pages Hi, I have a tag ... but I would to show the element of the list in different page. Infact the list's elements are the result of a search in a SearchEngine so I would have the links to page 1 2 3 4 5... and for each page I want view only x results. For example,if I have 100 results and I want to show only 10 results for each page, so I have in the page the links page 1 2 3 4 5 6 7 8 9 10 Daniele - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
result in different pages
Hi, I have a tag ... but I would to show the element of the list in different page. Infact the list's elements are the result of a search in a SearchEngine so I would have the links to page 1 2 3 4 5... and for each page I want view only x results. For example,if I have 100 results and I want to show only 10 results for each page, so I have in the page the links page 1 2 3 4 5 6 7 8 9 10 Daniele - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Clearing form value
i am not using Spring at all.here is the code for my configuration and action class my *Quotation.jsp page* by which i am adding data <%@ taglib prefix="s" uri="/struts-tags" %> Quotation Form Quotation Form *my action class* package raisonne.billgeneration; import com.opensymphony.xwork2.ActionSupport; import raisonne.billgeneration.GetBillConnection; public class SaveBillingData extends ActionSupport{ /** * */ private static final long serialVersionUID = -5856152810070496725L; private int rowInserted=0; private String date=null; private String voucherNumber=null; private String customerName=null; private String address=null; private String contactNo=null; private String itemName=null; private String purity=null; private double grossWeight=0.0; private double netWeight=0.0; private double diamondWeight=0.0; private double goldRate=0.0; private double amount=0.0; /* Getter and Setter Method */ public String execute() throws Exception{ GetBillConnection billCollection =new GetBillConnection(); rowInserted=billCollection.AddBillingData(getDate(),getVoucherNumber(), getCustomerName(),getAddress(),getContactNo(), getItemName(),getPurity(),getGrossWeight(), getNetWeight(),getDiamondWeight(),getGoldRate(),getAmount()); if(rowInserted>0){ addActionMessage("Quotation data has been submitted successfully"); return SUCCESS; } else{ addActionMessage("Error while saving Quotation data, Pleaes retry"); return INPUT; } } } lastly *Struts.xml file* /BillGeneration/Quotation.jsp /Login/Login.jsp -aum On 4/19/08, Nils-Helge Garli Hegvik <[EMAIL PROTECTED]> wrote: > > It would be a lot easier helping if you show us some configuration > files and code > > Nils-H > > On Sat, Apr 19, 2008 at 6:59 AM, aum strut <[EMAIL PROTECTED]> wrote: > > yes you are right > > > > not providing complete information in one mail is really not good > > > > i wil take this in to account in future... > > > > well i am not using spring in my application i have a simple form which > is > > sending the input values to my action where i am adding these in to the > data > > base using simple jdbc call everything is working fine i am even > getting > > back the success response in my add form. > > > > i am not able to understand what u mean by "not have your action > defined as > > being "prototype" > > scope" > > > > aum > > > > > > > > > > On 4/19/08, Dave Newton <[EMAIL PROTECTED]> wrote: > > > > > > Are you using Spring? > > > > > > Would it be possible for you to provide more useful information in > your > > > initial emails rather than generating a stream of a half-dozen or > more? > > > It's > > > rather frustrating; we've gone through this before. > > > > > > One common error is to not have your action defined as being > "prototype" > > > scope. Since actions are instantiated on each request (normally) it's > not > > > typical to see this behavior without some effort on your part or > > > mis-configuration. > > > > > > Dave > > > > > > --- aum strut <[EMAIL PROTECTED]> wrote: > > > > > > > currently i am using struts-2.0.11.1 > > > > > > > > On 4/19/08, Dave Newton <[EMAIL PROTECTED]> wrote: > > > > > > > > > > Which version of Struts? > > > > > > > > > > --- aum strut <[EMAIL PROTECTED]> wrote: > > > > > > > > > > > Hi all, > > > > > > > > > > > > a little point which i want to know. > > > > > > i have a form by which we can add billing detais in the > database > > > > > > > > > > > > form is working fine, it is adding the value to the database as > > > > > expected, > > > > > > the problem whcih i am facing is even after successfully > submitting > > > the > > > > > > values, it is not clearing the form values which has been added > > > > > > > > > > > > i can clear the fields values using java script,but i want to > know > > > is > > > > > it > > > > > > possible using Struts2,is theer any was that when ever data is > > > > submitted > > > > > > successfully in the database form fields values should get > cleared. > > > > > > > > > > > > > > > > > > any help in this regard will be much appriciated. > > > > > > > > > > > > > > > > > > thanks in advance > > > > > > --aum > > > > > > > > > > > > > > > > > > > > > > - > > > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > > > > > > > > > > > > - > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >
Re: Clearing form value
It would be a lot easier helping if you show us some configuration files and code Nils-H On Sat, Apr 19, 2008 at 6:59 AM, aum strut <[EMAIL PROTECTED]> wrote: > yes you are right > > not providing complete information in one mail is really not good > > i wil take this in to account in future... > > well i am not using spring in my application i have a simple form which is > sending the input values to my action where i am adding these in to the data > base using simple jdbc call everything is working fine i am even getting > back the success response in my add form. > > i am not able to understand what u mean by "not have your action defined as > being "prototype" > scope" > > aum > > > > > On 4/19/08, Dave Newton <[EMAIL PROTECTED]> wrote: > > > > Are you using Spring? > > > > Would it be possible for you to provide more useful information in your > > initial emails rather than generating a stream of a half-dozen or more? > > It's > > rather frustrating; we've gone through this before. > > > > One common error is to not have your action defined as being "prototype" > > scope. Since actions are instantiated on each request (normally) it's not > > typical to see this behavior without some effort on your part or > > mis-configuration. > > > > Dave > > > > --- aum strut <[EMAIL PROTECTED]> wrote: > > > > > currently i am using struts-2.0.11.1 > > > > > > On 4/19/08, Dave Newton <[EMAIL PROTECTED]> wrote: > > > > > > > > Which version of Struts? > > > > > > > > --- aum strut <[EMAIL PROTECTED]> wrote: > > > > > > > > > Hi all, > > > > > > > > > > a little point which i want to know. > > > > > i have a form by which we can add billing detais in the database > > > > > > > > > > form is working fine, it is adding the value to the database as > > > > expected, > > > > > the problem whcih i am facing is even after successfully submitting > > the > > > > > values, it is not clearing the form values which has been added > > > > > > > > > > i can clear the fields values using java script,but i want to know > > is > > > > it > > > > > possible using Struts2,is theer any was that when ever data is > > > submitted > > > > > successfully in the database form fields values should get cleared. > > > > > > > > > > > > > > > any help in this regard will be much appriciated. > > > > > > > > > > > > > > > thanks in advance > > > > > --aum > > > > > > > > > > > > > > > > > - > > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > > > > > > - > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]