• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 250
  • Last Modified:

What should I put in input field ?

Hi,

when a user needs to login, I need to validate its input.
When his input is invalid, I need to display error messages below the textfields.
He can login via a menu on the left,
that means that he can login from all the pages of the website (since that menu is displayed on the left in almost every page).
So what do I need to specify in input attribute ?

<action
            path="/Login"
            type="controllers.submits.LoginAction"
            name="loginForm"
            input=""   <--------- ?
            validate="true"
            scope="request">
</action>
0
matthew016
Asked:
matthew016
  • 18
  • 18
1 Solution
 
jaggernatCommented:
The value of input is a mapping to the document that
submits the form.  For this example, it's the page that presents you with
the username/password screen.

This way if there is an error, you can send the user back to the input
screen that they came from.

example
<action-mappings>
<action path="/logon" type="org.apache.struts.example.LogonAction"
 name="logonForm"
 scope="request"
 input="/logon.jsp"  ---your page or tile which has the username/ password field
 unknown="false" validate="true" />
</action-mappings>

0
 
matthew016Author Commented:
jaggernat, as I said above,
There is no log-in page.

He can login-in from every page.
index.jsp, profile.jsp, chat.jsp, ...

they all include "menu_left.jsp" that contains the form to log-in (the document u are talking about),
it's a jsp ... but not designed as a stand alone jsp.
0
 
jaggernatCommented:
but why do you want users to log in from every page? once user is logged in , you dont have to show him the login page again until he logs out. dont you think so?

0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
matthew016Author Commented:
When a user is logged in, I don't show him the login form on the left anymore.
It's like here on EE, on the left side u have the login-form, then when u are logged in, u see your nickname and a list of functionnalietes u can do.
And u can log in from every page.
Same thing on my website.

0
 
jaggernatCommented:
>>>>they all include "menu_left.jsp" that contains the form to log-in

ok and what includes "menu_left.jsp"  .is it a tile ? if yes, whats the name of the tile?
0
 
matthew016Author Commented:
menu_left.jsp includes nothing. it's like the header or the footer.

index.jsp includes menu_left.jsp, header.jsp, footer.jsp, info.jsp ...
chat.jsp includes menu_left.jsp, header.jsp, footer.jsp,info.jsp  ...
xyz.jsp includes menu_left.jsp, header.jsp, footer.jsp,info.jsp  ...
etcetera.

** tiles-defs.xml **

<tiles-definitions>
  <!-- ========== LAYOUTS ========== -->
  <!-- Base Layout -->
  <definition name=".base"         page="/layout/base.jsp">
    <put      name="header"       value="/incl/header/header.jsp"/>
    <put      name="info"         value="/incl/info/info.jsp"/>
    <put      name="menu_top"         value="/incl/menu_top/menu_top.html"/>
    <put      name="menu_left"         value="/incl/menu_left/menu_left.jsp"/>
    <put      name="center"         value="/incl/blank.jsp"/>
    <put      name="footer"       value="/incl/footer/footer.jsp"/>
  </definition>
  <!-- ========== PAGES ========== -->
  <definition       name=".index"       extends=".base">
      <put          name="center"       value="/incl/center/c_index.jsp"/>
  </definition>
  <definition       name=".chatform"       extends=".base">
    <put            name="center"       value="/incl/center/c_chat_form.jsp"/>
  </definition>
  <definition      name=".applet">
    <put            name="center" value="/incl/center/c_applet.jsp"/>
  </definition>
  <definition      name=".registration"      extends=".base">
    <put            name="center"                     value="/incl/center/c_registration.jsp"/>
  </definition>
</tiles-definitions>


**index.jsp**
<tiles:insert definition=".index" flush="true"/>

**chatform.jsp**
<tiles:insert definition=".chatform" flush="true"/>

...
0
 
jaggernatCommented:
multiple tiles might have menu_left.jsp but i want the name of the first tile which has the menu_left.jsp which you are validating.
0
 
jaggernatCommented:
try

input="/index.jsp"

and

input="/incl/menu_left/menu_left.jsp"


0
 
matthew016Author Commented:
Ok, i'll try that,
but u know what ?
I still ahve this stupid error :

The validate attr and input attr didnt change anything



3-nov.-2006 23:38:32 org.apache.struts.validator.DynaValidatorForm validate
GRAVE: No such validation method: org.apache.struts.validator.FieldChecks.validateRequired(java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, javax.servlet.http.HttpServletRequest)
org.apache.commons.validator.ValidatorException: No such validation method: org.apache.struts.validator.FieldChecks.validateRequired(java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, javax.servlet.http.HttpServletRequest)
      at org.apache.commons.validator.ValidatorAction.loadValidationMethod(ValidatorAction.java:603)
      at org.apache.commons.validator.ValidatorAction.executeValidationMethod(ValidatorAction.java:533)
      at org.apache.commons.validator.Field.validateForRule(Field.java:766)
      at org.apache.commons.validator.Field.validate(Field.java:846)
      at org.apache.commons.validator.Form.validate(Form.java:290)
      at org.apache.commons.validator.Validator.validate(Validator.java:354)
      at org.apache.struts.validator.DynaValidatorForm.validate(DynaValidatorForm.java:117)
      at org.apache.struts.chain.commands.servlet.ValidateActionForm.validate(ValidateActionForm.java:53)
      at org.apache.struts.chain.commands.AbstractValidateActionForm.execute(AbstractValidateActionForm.java:100)
      at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:48)
      at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
      at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
      at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
      at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:280)
      at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1858)
      at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:459)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
      at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
      at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
      at java.lang.Thread.run(Thread.java:595)
0
 
matthew016Author Commented:
:-)
0
 
jaggernatCommented:
do u have

<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
        <set-property  
                  property="pathnames"  
                 value="/WEB-INF/ch12/validator-rules.xml, /WEB-INF/ch12/validator.xml" />

          </plug-in>


 
in struts-config.xml
0
 
jaggernatCommented:
ignore above post

see if you have this in struts-config


<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
            <set-property property="pathnames" value="/WEB-INF/validator-rules.xml, /WEB-INF/validation.xml" />
      </plug-in>

      
0
 
jaggernatCommented:
also , can you get the latest version of struts.jar
0
 
matthew016Author Commented:
Dear jaggernat,
the Validator problem is fixed now ...

We can get back to the real question :
what do i need to put in input.

Actually it would be something like index.jsp,
but what I think is annoying is that, if he gets into a page he wants, then logs in,
he need to go back to the page...

Here in EE,
when u log in, u are not in the index if u log in from a specific page,
like a question page,
u stay in that page.
0
 
matthew016Author Commented:
Without Struts what I could do is, if I'm not wrong :
put a hidden field in the login form (in menu_left) with the url of the current field,
then if error or succes, get back to that same URL.

I think I can't achieve this now because I'm using Struts now ...

0
 
matthew016Author Commented:
*of the current field must be of the current page
0
 
jaggernatCommented:
first put this and tell me what you see



input="/index.jsp"


if you dont see any validation error

 try

input="/incl/menu_left/menu_left.jsp"

0
 
matthew016Author Commented:
when I do :

1) input="/index.jsp"

when form is not valid : i go to index.jsp
So if the user, found "finally" the page he wanted, e.g. chat_form.jsp,
if he logs in, and it's incorrect, he goes to index.jsp => not good.

2) input="/incl/menu_left/menu_left.jsp"

This isn't good, can't see footer, header, , ... since it has not the insert tile tag.
it's just a comonent of the view.
0
 
jaggernatCommented:
I was just making sure that you see the validation error messages. Do you see them?
where you want to display the error message is up tp you.


>>>when form is not valid : i go to index.jsp

does this behaviour occur once you put  input="/index.jsp"    ?


0
 
matthew016Author Commented:
I think u don't understand what I mean.

The form to log in is in the left menu, included to all the pages.

if I put input="/index.jsp" when an error occur I will see the error messages on the left, that's ok, , but the content is the index.
If he was in another page (for example a page that allow him to see his mail) and he wants to log in, and an error occur, he is forwxarded to the index content.
0
 
jaggernatCommented:
where do you want to disply the error messages?
0
 
matthew016Author Commented:
The error messages are displayed in the left menu,
that's all right.

(http://www.lehall.org   leave the fields blank and click on "Validate")
The problem is that I am always forwarded to index.jsp
if I put input="/index.jsp"

I want the user to stay on the current page.
0
 
jaggernatCommented:
No , i am not forwarded to index.jsp. I stay on the same page and see the error messages

by the way, nice website :)
0
 
matthew016Author Commented:
yes, that's because the page is index.jsp ...
so indeed if there is error u stay in index.jsp

and this is not the struts version, it's still in develompent, it's just jsp/servlet version what u see.
0
 
matthew016Author Commented:
but let's say u are in registration page, u want to login and there is error, u are back in index.jsp
0
 
matthew016Author Commented:
Because, they all include the menu left form, to log-in.

So when you are inr egistration.jsp, and u want to login, if there is error u go to index.jsp because of this :

<action
            path="/Login"
            type="controllers.submits.LoginAction"
            name="loginForm"
            input="/index.jsp"
            validate="true"
            scope="request">
</action>

and u lose the page where u were.

0
 
jessegivyDeveloperCommented:
Sorry to interupt, and please forgive me for being obtuse, but I've not seen this action tag  before, and I'm not sure what the heck you guys are talking about.  I am however sure that you can get the address of your current page either by use of JSP or JavaScript.  

Would this be acceptable:

input="javascript:window.location"

....I can't remember the function in JSP I think it's getContextPath() which would look somethin like this?

input="<%=request.getContextPath()%>"

...Or am I completely off base?
0
 
matthew016Author Commented:
jessegivy, this is a struts question
sorry, wasn't clear in the title
0
 
jaggernatCommented:
can you try

input=".index"
0
 
jaggernatCommented:
>>>>but let's say u are in registration page, u want to login and there is error, u are back in index.jsp


i see your problem. so can your user go directly to the registration page and log in from there?

 

0
 
jaggernatCommented:
hmmm ...unique scenario.  

one thing that comes to my mind is the problem can be solved if we can change the value of
input=""  attribute.
when logging from index page it should be input="/index.jsp".
when logging from registration page it should be input="/registration.jsp" (or something like that which shows errors in registration page)..

and so on..

0
 
matthew016Author Commented:
Yes that's it ...
>> input=".index"
That didn't work
0
 
matthew016Author Commented:
Maybe I found a solution :
put the page he is in the session,
then in input="" put an action like input="/Error.do"
then in Error action get the page from the session and forward to it.
I'll try that
0
 
jaggernatCommented:
yes..good one  :)

0
 
matthew016Author Commented:
Ok, my solution works,
I have like 5 more questions,
please stay tuned :-)
0
 
jaggernatCommented:
bingo!, well done. i am at work dude, but still i'll try to help!

0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 18
  • 18
Tackle projects and never again get stuck behind a technical roadblock.
Join Now