Solved

What should I put in input field ?

Posted on 2006-11-23
37
244 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 18
  • 18
37 Comments
 
LVL 10

Expert Comment

by:jaggernat
ID: 18005028
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
ID: 18005038
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
ID: 18005047
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

Author Comment

by:matthew016
ID: 18005061
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
ID: 18005067
>>>>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
ID: 18005089
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
ID: 18005091
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
ID: 18005098
try

input="/index.jsp"

and

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


0
 
LVL 9

Author Comment

by:matthew016
ID: 18005100
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
ID: 18005102
:-)
0
 
LVL 10

Expert Comment

by:jaggernat
ID: 18005123
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
ID: 18005126
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
ID: 18005146
also , can you get the latest version of struts.jar
0
 
LVL 10

Expert Comment

by:jaggernat
ID: 18005163
0
 
LVL 9

Author Comment

by:matthew016
ID: 18009627
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
ID: 18009660
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
ID: 18009669
*of the current field must be of the current page
0
 
LVL 10

Expert Comment

by:jaggernat
ID: 18010079
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
 
LVL 9

Author Comment

by:matthew016
ID: 18011070
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
ID: 18011618
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
ID: 18011626
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
ID: 18011748
where do you want to disply the error messages?
0
 
LVL 9

Author Comment

by:matthew016
ID: 18011818
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
ID: 18011825
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
ID: 18011832
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
ID: 18011835
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
ID: 18011843
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
ID: 18012182
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
ID: 18012249
jessegivy, this is a struts question
sorry, wasn't clear in the title
0
 
LVL 10

Expert Comment

by:jaggernat
ID: 18012393
can you try

input=".index"
0
 
LVL 10

Expert Comment

by:jaggernat
ID: 18012405
>>>>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
ID: 18012423
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
ID: 18012697
Yes that's it ...
>> input=".index"
That didn't work
0
 
LVL 9

Author Comment

by:matthew016
ID: 18012719
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
ID: 18012793
yes..good one  :)

0
 
LVL 9

Author Comment

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

Expert Comment

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

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
jersey maven project error 7 152
attribute vs parameter and setter vs add method 17 97
reflections, dynamic class loading 3 84
ejb on wildfly 5 63
When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
The goal of this blog is to: > note what has impeded us from reaching effective life on-call > provide 3 steps to mastering life on-call > highlight what will be achieved with effective life on-call
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

739 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