Cant get css, js files if not using .do extension

2009-05-12 Thread KE LI
Dear all,
  I had met a strange problem:
  If I modified the struts.xml file and I dont want to use .do extension for
actions. I set it as /* . For example, the previous link is
http://localhost:8080/test.do. Now after modification it becomes:
http://localhost:8080/test.
  But when I restart the server and run it, the error appears in the jsp
file which I include a css file, the link is like ../css/main.css. The
console said:
  15545 [http-8080-2] ERROR org.apache.struts2.dispatcher.Dispatcher  -
Could not find action or result
There is no Action mapped for namespace / and action name main.css. -
[unknown location]
  I am sure that the link for this css file is correct.(If I still
configured the action extension to .do, all things run correctly...)
  Could any people tell me how to solve this? Thank you very much!

-- 
Best Regards,
Licco


Dynamic TextFields in Struts 2

2009-01-19 Thread KE LI
Dear All,  I want to do something like this:
  in my action i create:
  ListString textFields = new ArrayListString();
  and i tried to write set method in 2 ways:
  1. public void setTextFields (ListString textFields)
  2. public void setTextFields(String text)
  {
textFields.add(text);
  }

  and in my jsp, i want to get something like this:
  s:iterator ...
  s:textfield name=textFields[%{#status.index}]/
  /s:iterator

  But I found that for both setter methods, there are errors:
  com.opensymphony.xwork2.util.OgnlValueStack  - Caught an exception while
evaluating expression 'test_string[0]' against value stack
  java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
  at java.util.ArrayList.RangeCheck(ArrayList.java:547)

  Can anyone help me on how to create such a dynamic textFields (Considering
action implementation)? Thanks in advance!

-- 
Best Regards,
Licco


Re: Dynamic TextFields in Struts 2

2009-01-19 Thread KE LI
Hi Dave and Shashi,
  Thanks for you two's quick reply!! It does help~:) I just got up, lol.
Licco

2009/1/20 sasikumar sasikumar.sugu...@deciphar.com

 Hi,
  you dont have to explicitly add the values to the list in the setter
 methods, since the framework will do that for you ,
 also you dont have to explicitly provide the index in the property field
 (name) (even though it will work with explicit indexing as well) . refer the
 fallowing code for help , make sure you have the getters and  setters
 created in your model or action respectively.

 s:iterator value=trainingSessionDetails
   id=trainingSessionDetailsL status=status
   tds:textfield name=trainingSessionName
 id=sessionNameL
   value=%{#trainingSessionDetailsL.sessionName}
 size=8/s:textfield/td
   tds:textarea name=trainingSessionDescription
   id=sessionDescriptionL

 value=%{#trainingSessionDetailsL.sessionDescription} //td
   tds:textfield name=trainingSessionStartDate
   id=sessionStartDateL%{#status.index}
   value=%{#trainingSessionDetailsL.sessionStartDate}
 size=16 //td
   tds:textfield name=trainingSessionEndDate
   id=sessionEndDateL%{#status.index}
   value=%{#trainingSessionDetailsL.sessionEndDate}
 size=16 //td
   /tr
   /s:iterator

 Shashi


 Dear All,  I want to do something like this:
  in my action i create:
  ListString textFields = new ArrayListString();
  and i tried to write set method in 2 ways:
  1. public void setTextFields (ListString textFields)
  2. public void setTextFields(String text)
  {
textFields.add(text);
  }

  and in my jsp, i want to get something like this:
  s:iterator ...
  s:textfield name=textFields[%{#status.index}]/
  /s:iterator

  But I found that for both setter methods, there are errors:
  com.opensymphony.xwork2.util.OgnlValueStack  - Caught an exception while
 evaluating expression 'test_string[0]' against value stack
  java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
  at java.util.ArrayList.RangeCheck(ArrayList.java:547)

  Can anyone help me on how to create such a dynamic textFields
 (Considering
 action implementation)? Thanks in advance!





  -
 To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
 For additional commands, e-mail: user-h...@struts.apache.org




-- 
Best Regards,
Licco


Re: Dynamic s:checkbox name?

2009-01-18 Thread KE LI
Got it, quite useful. Thanks for all you guys' help!

2009/1/18 abhijit.sulh...@gmail.com

 Makes perfect sense if interested in matching the values from checkbox
 list. Another variation, I think in that case would be to use the
 'fieldValue' instead of name; that way the set values can  be easier
 to retrieve as a list using the name encapsulator.

 s:iterator value=test_list status=status
 s:checkbox name=test_string value=true fieldValue=%{top}
   /s:iterator

 - Abhijit Sulhyan

 On 1/18/09, Wes Wannemacher w...@wantii.com wrote:
  On Sunday 18 January 2009 00:47:51 Nuwan Chandrasoma wrote:
s:iterator value=test_list status=status
  s:checkbox name=test_string_%{#status.index} value=true
/s:iterator
 
  Thanks,
 
  Nuwan C
 
 
  Nuwan,
 
  I'm not sure if that is what he is intending. It will work, but for what
  seems
  to be the wrong reasons. If test_list contains the values to iterate
 over,
  then I would use those, rather than the loop index.
 
  s:iterator value=test_list status=status
   s:checkbox name=%{'test_string_' + top} value=true
/s:iterator
 
  This is a slightly different variation of the OGNL, as I enclosed the
 whole
  expression. Also, top will point to the value on the top of the Value
  Stack,
  which will contain the value pushed onto it by the s:iterator tag.
 
  -Wes
  --
 
  Wes Wannemacher
  Author - Struts 2 In Practice
  Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
  http://www.manning.com/wannemacher
 
 
  -
  To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
  For additional commands, e-mail: user-h...@struts.apache.org
 
 

 -
 To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
 For additional commands, e-mail: user-h...@struts.apache.org




-- 
Best Regards,
Licco


Dynamic s:checkbox name?

2009-01-17 Thread KE LI
Dear All,  I am confusing about how to write dynamic s:checkbox names in s2.
For example,
  s:iterator value=test_list status=status
s:checkbox name=test_string_? value=true
  /s:iterator

  I want to achieve the result as:
  s:checkbox name=test_string_0 value=true
  s:checkbox name=test_string_1 value=true
  s:checkbox name=test_string_2 value=true
  s:checkbox name=test_string_3 value=true
  s:checkbox name=test_string_4 value=true
  etc.

  The main problem is that i dont know how to write the right ognl
expression in the code above(around the ? position). Can anyone help me?
Thanks in advance.

-- 
Best Regards,
Licco


Re: How can these query data be got?

2008-12-02 Thread KE LI
Hi Dave,
  Thanks for your quick reply. Suppose that I input this link
xxx/welcome.do?param1=helloparam2=worldparamList=element1paramList=element2paramList=...
into the link bar in the browser and run it. How can S2 knows to put hello
into param1 and world into param2 in the welcome action object?
  Could you please kindly explain the procedure? Or lets say, if I define
another field param4, why not giving hello to param4 instead of
param1?
  Besides, suppose that I just run this link
xxx/welcome.do?param1=helloparam2=worldparamList=element1paramList=element2paramList=...
in the browser, only the default method execute will be called, right?
  Thanks a lot!

2008/12/2 Dave Newton [EMAIL PROTECTED]

 --- On Tue, 12/2/08, KE LI wrote:
public class welcome implements Action {
 private List paramList;
 setters
 public String execute() throws Exception {
  paramList = new ArrayList();
  return SUCCESS;
 }
}
 
  Then if I input the URL:
 
 xxx/welcome.do?param1=helloparam2=worldparamList=element1paramList=element2paramList=...
I found that param1 will be given the value hello, param2
  will be given the value world but of course paramList will
  not be given element1,2,3...etc. I want to ask: [...]

 The first issue I see is that you're creating a new list in the execute()
 method. The execute() method is executed after the interceptors set the
 action properties from the form data--so you're wiping out the work the
 interceptors did.

 Dave


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




-- 
Best Regards,
Licco


Re: Problem when using result type=redirect-action

2008-12-02 Thread KE LI
admin{1}

2008/12/2 ravindra [EMAIL PROTECTED]

 I think some thing is wrong at these lines,

 result name=* type=redirect-action
 ViewTestedLetters
 /admin
 1
 /result

 Your mapping should be like,
 result name=* type=redirect-actionViewTestedLetters/result

 All the best,

 -Original Message-
 From: holod [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, December 02, 2008 2:50 PM
 To: user@struts.apache.org
 Subject: Problem when using result type=redirect-action


 When I try to redirect action and set parameter value to it, I get an
 exception:

 [02.12.08 12:11:33:705 MSK] 0031 OgnlUtil  W
 com.opensymphony.xwork2.util.OgnlUtil internalSetProperty Caught
 OgnlException while setting property 'page' on type
 'org.apache.struts2.dispatcher.ServletActionRedirectResult'.
 ognl.NoSuchPropertyException:
 org.apache.struts2.dispatcher.ServletActionRedirectResult.page
at
 ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:132)
at

 com.opensymphony.xwork2.util.OgnlValueStack$ObjectAccessor.setProperty(OgnlV
 alueStack.java:81)
at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:1656)
at ognl.ASTProperty.setValueBody(ASTProperty.java:101)
at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177)
at ognl.SimpleNode.setValue(SimpleNode.java:246)
at ognl.Ognl.setValue(Ognl.java:476)
at com.opensymphony.xwork2.util.OgnlUtil.setValue(OgnlUtil.java:186)
at

 com.opensymphony.xwork2.util.OgnlUtil.internalSetProperty(OgnlUtil.java:360)
at
 com.opensymphony.xwork2.util.OgnlUtil.setProperties(OgnlUtil.java:76)
at
 com.opensymphony.xwork2.util.OgnlUtil.setProperties(OgnlUtil.java:49)


 my struts.xml:

 action name=ViewTestedLetters class=admin.AdminViewTreatmentAction
 method=viewTested
result name=success /admin/treatmentadm.jsp/result
 /action

 action name=ApproveLetters class=admin.AdminEditTreatmentAction
 method=approve
result name=* type=redirect-action
 ViewTestedLetters
 /admin
 1
 /result
 /action

 These two action classes have field:
 private int page;

 These two action classes have getter and setter for the field named page:
 public void setPage(int page) {
this.page = page;
 }

 public int getPage() {
return page;
 }

 Why does I get such exception?


 P.S.
 I've used this tutorial:
 http://struts.apache.org/2.x/docs/redirect-action-result.html


 --
 View this message in context:

 http://www.nabble.com/Problem-when-using-result-type%3D%22redirect-action%22
 -tp20788608p20788608.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]





 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




-- 
Best Regards,
Licco


How can these query data be got?

2008-12-01 Thread KE LI
Hi All,
  I am quite confusing about this problem:
  Suppose this is an action:
  public class welcome implements Action
  {
   private String param1;
   private String param2;
   private List paramList;

   getters
   setters

   public String execute() throws Exception
   {
paramList = new ArrayList();
return SUCCESS;
   }
  }

  Then if I input the URL:
xxx/welcome.do?param1=helloparam2=worldparamList=element1paramList=element2paramList=...
  I found that param1 will be given the value hello, param2 will be given
the value world but of course paramList will not be given
element1,2,3...etc. I want to ask:
  1. How can Struts2 get this value and give them to the parameters in the
action. As param1 and param2.
  2. How to solve the paramList problem that I can put a list of the same
kind of data into a dynamic list as paramList when I type / click the URL
like the example I gave above?
   PS: This will be used in pagination especially in the page tag which I
wrote myself.
   Thanks a lot in advance!
-- 
Best Regards,
Licco


Re: Pagination Questions

2008-11-30 Thread KE LI
Hi Adam,
  Thanks for your reply. I am doing pagination like this now since I found
that using index to do searching from a range of record is quite fast, much
faster than I thought before. So I just use your suggested solution.


2008/11/30 Adam Ruggles [EMAIL PROTECTED]


 Personally I think it would be a bad idea to buffer the data from the db,
 since most users when performing a search will only look at the first page
 of results.  It would be better to simply return a limited set of results
 from the DB.  Otherwise you might be fetching data the user will never see.

 What I usually do is create an object that stores a list of the current
 result set and the total number of results.  This object I create in the
 data layer and requires two db calls.  One to get a limited list of results
 and the second to get the total item count.

 In the action I have an offset and resultsPerPage variable that I pass to
 my
 data layer.  I don't know what database you're using but most allow you to
 limit the results, using an offset and number of results.


 KE LI-2 wrote:
 
  Dear All,
  I am currently working on pagination to the result of search result. I
  want to ask which solution is better?
  1. After user chooses some criterias and then clicks the search
  button, the server will return the size of search result and the
  objects of first page of the search result. Then when user clicks the
  different page number, the server will get the data for that page from
  DB. But for this solution, it requires DB access when you click the
  page number.
 
  2.After user clicks the search button, the server will get all the
  objects(like all the films which the user wanna.). Then when user
  clicks different page number, the server will just return the data
  from memory. This seems to reduce the DB access times.
 
  3. Use some preload method to store the data for the next few pages in
  a buffer.
 
  Which solution will achieve a fast search and reduce the access load
  to the DB?
 
  Thanks a lot for your feedback!
 
  Li, Ke (Licco)
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

 --
 View this message in context:
 http://www.nabble.com/Pagination-Questions-tp20744884p20749894.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]




-- 
Best Regards,
Licco


S2 Side Integrated with UI side(js + ajax)

2008-11-25 Thread KE LI
Dear All,
  I am a newbie to Struts2. I found that tag library in Struts2 is quite
useful and convenience. But I have some problems with integration with our
UI developer. Since he doesn't think that Struts2' tags are good looking
enough and he want to develop the UI by his way. But if we dont use S2's
tag, I found that I dont how to get values from action class. (S2's tag will
get them from valueStack automatically.)
  For example, I can make a CheckboxList by using:  s:checkboxlist
list=xxInitList/  I know that xxInitList will be get from the valueStack
automatically. But my UI developer want me to show the items in the
xxInitList by using li in HTML and then he will make the checkboxlist by
nicer solution. So how can I solve this problem by getting values from
action by not using S2 tags? And what's the best practise to integrate UI
side code?
  This question may be quite trivial for you guys...But I am really confused
with it...Thank you very much in advance!

-- 
Best Regards,
Licco


A Strange Error with My Own Tag

2008-11-18 Thread KE LI
Guys,  I am writing my own tag as:
  public class PageTag extends ComponentTagSupport
  For ComponentTagSupport, it's
org.apache.struts2.views.jsp.ComponentTagSupport. But the error appears, it
says:
  Description Resource Path Location Type   The project was not built since
its build path is incomplete. Cannot find the class file for
javax.servlet.jsp.tagext.BodyTagSupport. Fix the build path then try
building this project Unknown Java Problem
  I did some google search but cannot solve it by myself. Can anyone help
me? Thank you very much!

-- 
Best Regards,
Licco


Re: A Strange Error with My Own Tag

2008-11-18 Thread KE LI
Got it.Thanks a lot!

2008/11/18 Lukasz Lenart [EMAIL PROTECTED]

 You are missing reference to javaee.jar library and it's not related
 to Struts project


 Regards
 --
 Lukasz
 http://www.lenart.org.pl/

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




-- 
Best Regards,
Licco


Re: A Strange Error with My Own Tag

2008-11-18 Thread KE LI
For further information: The Eclipse said: The type
javax.servlet.jsp.tagext.BodyTagSupport cannot be resolved. It is indirectly
referenced from required .class files

2008/11/18 KE LI [EMAIL PROTECTED]

 Guys,  I am writing my own tag as:
   public class PageTag extends ComponentTagSupport
   For ComponentTagSupport, it's
 org.apache.struts2.views.jsp.ComponentTagSupport. But the error appears,
 it says:
   Description Resource Path Location TypeThe project was not built
 since its build path is incomplete. Cannot find the class file for
 javax.servlet.jsp.tagext.BodyTagSupport. Fix the build path then try
 building this project Unknown Java Problem
   I did some google search but cannot solve it by myself. Can anyone help
 me? Thank you very much!

 --
 Best Regards,
 Licco




-- 
Best Regards,
Licco