Solved

What should I put in input field ?

Posted on 2006-11-23
37
229 Views
Last Modified: 2010-04-01
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
Comment
Question by:matthew016
  • 18
  • 18
37 Comments
 
LVL 10

Expert Comment

by:jaggernat
Comment Utility
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
 
LVL 9

Author Comment

by:matthew016
Comment Utility
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
 
LVL 10

Expert Comment

by:jaggernat
Comment Utility
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
 
LVL 9

Author Comment

by:matthew016
Comment Utility
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
 
LVL 10

Expert Comment

by:jaggernat
Comment Utility
>>>>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
 
LVL 9

Author Comment

by:matthew016
Comment Utility
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
 
LVL 10

Expert Comment

by:jaggernat
Comment Utility
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
 
LVL 10

Expert Comment

by:jaggernat
Comment Utility
try

input="/index.jsp"

and

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


0
 
LVL 9

Author Comment

by:matthew016
Comment Utility
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
 
LVL 9

Author Comment

by:matthew016
Comment Utility
:-)
0
 
LVL 10

Expert Comment

by:jaggernat
Comment Utility
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
 
LVL 10

Expert Comment

by:jaggernat
Comment Utility
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
 
LVL 10

Expert Comment

by:jaggernat
Comment Utility
also , can you get the latest version of struts.jar
0
 
LVL 10

Expert Comment

by:jaggernat
Comment Utility
0
 
LVL 9

Author Comment

by:matthew016
Comment Utility
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
 
LVL 9

Author Comment

by:matthew016
Comment Utility
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
 
LVL 9

Author Comment

by:matthew016
Comment Utility
*of the current field must be of the current page
0
 
LVL 10

Expert Comment

by:jaggernat
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 9

Author Comment

by:matthew016
Comment Utility
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
 
LVL 10

Expert Comment

by:jaggernat
Comment Utility
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
 
LVL 9

Author Comment

by:matthew016
Comment Utility
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
 
LVL 10

Expert Comment

by:jaggernat
Comment Utility
where do you want to disply the error messages?
0
 
LVL 9

Author Comment

by:matthew016
Comment Utility
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
 
LVL 10

Expert Comment

by:jaggernat
Comment Utility
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
 
LVL 9

Author Comment

by:matthew016
Comment Utility
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
 
LVL 9

Author Comment

by:matthew016
Comment Utility
but let's say u are in registration page, u want to login and there is error, u are back in index.jsp
0
 
LVL 9

Author Comment

by:matthew016
Comment Utility
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
 
LVL 12

Expert Comment

by:jessegivy
Comment Utility
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
 
LVL 9

Author Comment

by:matthew016
Comment Utility
jessegivy, this is a struts question
sorry, wasn't clear in the title
0
 
LVL 10

Expert Comment

by:jaggernat
Comment Utility
can you try

input=".index"
0
 
LVL 10

Expert Comment

by:jaggernat
Comment Utility
>>>>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
 
LVL 10

Expert Comment

by:jaggernat
Comment Utility
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
 
LVL 9

Author Comment

by:matthew016
Comment Utility
Yes that's it ...
>> input=".index"
That didn't work
0
 
LVL 9

Author Comment

by:matthew016
Comment Utility
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
 
LVL 10

Accepted Solution

by:
jaggernat earned 500 total points
Comment Utility
yes..good one  :)

0
 
LVL 9

Author Comment

by:matthew016
Comment Utility
Ok, my solution works,
I have like 5 more questions,
please stay tuned :-)
0
 
LVL 10

Expert Comment

by:jaggernat
Comment Utility
bingo!, well done. i am at work dude, but still i'll try to help!

0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
logging jar 1 104
Display current date,month,and year to JTextField 3 41
parse example 13 85
maven project jars 7 46
This article explains in simple steps how to renew expiring Exchange Server Internal Transport Certificate.
A safe way to clean winsxs folder from your windows server 2008 R2 editions
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now