valuestack

How to use multiple forms / actions in a single view in Struts 2

我是研究僧i 提交于 2019-12-12 12:08:15
问题 I have a search box which is displayed on every page. The JSP code for the search box is inserted into every page via tiles. The search box has a form and an action class SearchAction which needs to preload some properties for drop down boxes. The SearchAction class has an input() method, which does this initialization. Some pages also have their own form in the main area. Also with their own action class. They also have an input() method which does some preloading. Is it possible to use two

What's the purpose of storing objects directly to the ValueStack/ActionContext?

╄→гoц情女王★ 提交于 2019-12-12 06:04:40
问题 Based from what I've researched, I've seen that tags such as <s:set> , <s:push> or by creating an <s:bean> are able to insert references directly to the ActionContext or ValueStack . This confuses me a lot because why can't you just have one dedicated place to store everything? Probably just put everything in the ActionContext since it's basically acts as a ServletContext . To make it even more confusing, if you wanted to access values in the ValueStack , you'll have to use Struts tags such

ModelDriven stopped working in Struts2

拥有回忆 提交于 2019-12-12 04:13:38
问题 I have used ModelDriven in my Action class, previously it was working fine, Now it has stopped working when I used <s:debug> tag of Struts in my jsp I found following result... ---------Updated Image----------- I'm accessing values in my jsp page as : <s:property value="categoryName"/> <s:property value="categoryId"/> // I typed here working fine, If I accessed them as : <s:property value="category.categoryName"/> <s:property value="category.categoryId"/> My questions are : Why I'm getting

Is the ValueStack life cycle across the application in struts2?

元气小坏坏 提交于 2019-12-12 04:12:55
问题 I can set a property on ValueStack in several ways. ValueStack stack = ActionContext.getContext().getValueStack(); stack.getContext().put("resultDTO",resultDTO); //1. creates a different branch //parallel to root stack.set("resultDTO", resultDTO); //2. pushes on root as a Map? stack.push(resultDTO); //3. pushes on root myActionClass.setProperty(); //4. normal action accessor I need to be able to get all these values back in JSP, freemarker and java like stack.findValue() or stack.findString()

Is there a way to bind OGNL with Struts2 UI tags

强颜欢笑 提交于 2019-12-12 02:44:50
问题 I'm developing a webapp using Struts2. I used to work with Struts1 is there a way to reference a session object directly to the JSP so that if I change the value in the formular, the value in the referenced session object will also be updated. <s:textfield name="%{#session.order.amount}"/> for e.g. I have a session object order which has attribute amount with getter and setter. it seems like, after I put some values into the textfield and then submit the page, the value in the session didn't

Struts 2 - Can I access properties of another action which is not on the ValueStack?

房东的猫 提交于 2019-12-11 10:29:38
问题 I have two JSP pages displaying two lists from two different actions: page A displays employee list, page B displays department list. Both pages have a common text field (included from a third JSP page) on the top to search employees by name: <s:form action="searchEmployeesByName"> <s:textfield name="employeeName" /> <s:submit> </s:form> The search action is a part of class EmployeeAction and I can load page A and perform searching without problems. However, when loading page B , I

Struts 2 - Accessing different properties on the ValueStack sharing the same name

泄露秘密 提交于 2019-12-11 00:35:34
问题 Struts 2 will resolve all property names during view rendering against the top object in the ValueStack first. But how can one access a property with the same name on the object lower on the stack? Example: Let's say I have an Action class called MyAction and it has a a logDate property. In the view rendered after this action is invoked, there's this: <s:iterator value="users" status="itStatus"> <s:property value="logDate"/> </s:iterator> Now imagine a User object also has a logDate property.

How to pass object from action class to JSP using Bean in Struts2?

▼魔方 西西 提交于 2019-12-10 10:58:46
问题 I have to send object of Bean class back to JSP from my action class. I am instantiating the Bean class in my action class and and setting some values in my Action class. ElasticitiesVariable elasticitiesVariable = new ElasticitiesVariable(); elasticitiesVariable.setAuto_Auto_cost_peak("-0.047"); elasticitiesVariable.setAuto_Ride_cost_peak("0.000"); elasticitiesVariable.setAuto_Van_cost_peak("0.000"); elasticitiesVariable.setAuto_Transit_cost_peak("0.050"); elasticitiesVariable.setAuto_Bike

How does Struts2 ValueStack take care of multiple requests

自古美人都是妖i 提交于 2019-12-09 01:47:36
问题 I understand ValueStack was introduced in Struts2 and one more change from Struts1 model is now a new ActionObject is instantiated for each request. So we can define instance variables without worrying about multi threading issues. The way interceptors and JSPs access the instance variables from the ActionObjects is through the ValueStack . But the way ValueStack is implemented (or at least used by Struts2 framework) is by ValueStack . to make the access easier so that we don't need to

Struts 2 using StringUtils in validator expersions

不想你离开。 提交于 2019-12-08 08:07:37
问题 We are using Struts 2 validators @FieldExpressionValidator and @ExpressionValidator . These validators check on OGNL expression. There are lots of cases where we deal with Strings in these expressions. expression="(captcha=='' && captcha== null || ....) We find it is very useful if we can use StringUtils ( isEmpty ,trimToEmpty,... ) here. As we set the struts.ognl.allowStaticMethodAccess to false, for security issues, we tried to solve it by adding this getter to action public StringUtils