You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Yee, Richard K,,DMDCWEST" <Ye...@osd.pentagon.mil> on 2003/12/08 23:02:17 UTC

RE: Please Help! Unable to Pass A Hidden Field To scaffold.Proces sAction

Caroline,
Are you having problems with the username or the keyName hidden variable? If
it is the username, then I'd suspect that request.getRemoteUser() in your
JSP is returning null.

Regards,

Richard

-----Original Message-----
From: Caroline Jen [mailto:jiapei_jen@yahoo.com] 
Sent: Monday, December 08, 2003 1:32 PM
To: Struts Users Mailing List
Subject: Re: Please Help! Unable to Pass A Hidden Field To
scaffold.ProcessAction


I did not mess up lowercase and uppercase of the
hidden field I want to pass from my JSP to the scaffold.ProcessAction.  If
it had been the lowercase/uppercase problem, I would have gotten a message
saying that the variable could not be recognized.  

I pass two hidden fields at the same time.  One of
them is successfully passed with correct value.  The
other is passed but its value shows a 'null' in the scaffold.ProcessAction.
What could go wrong?  Let me show my code again:

Two hidden fields: username and keyName are passed 
from a JSP via a SUBMIT button:

<req:isUserInRole role="editor">
<html:form action="/find/Category">
<% String username = request.getRemoteUser();%>
<html:hidden property="keyName"
value="journal_category"/>
<html:hidden property="username"
value="<%=username%>"/>
<html:submit>View Articles</html:submit>
</html:form>
</req:isUserInRole>

and an action mapping:

    <action
        roles="editor"
        path="/find/Category"
       
type="org.apache.struts.scaffold.ProcessAction"
       
parameter="org.apache.artimus.article.FindEditorData"
        name="articleForm"
        scope="request"
        validate="false">
       <forward
            name="success"
            path=".article.Result"/>
    </action>

The value of the 'username' is found to be a 'null' in
the FindEditorData.java while the value of keyName is successfully
retrieved.  In the browser, I got:

name=null; kn=journal_category; kv=null 

The code of my FindEditorData is shown below:

public final class FindEditorData extends Bean
{
   public Object execute() throws Exception
   {

   // Obtain username 
   String username = getUsername();
      
   EditorService service = new EditorService();
   String value = service.findEditorData( username );

   String property = getKeyName();
        
        if (( null==property ) || ( null==value )) 
        {
            StringBuffer sb = new StringBuffer();
            sb.append( "name=" );
            sb.append( username );
            sb.append( "; kn=" );
            sb.append( property );
            sb.append( "; kv=" );
            sb.append( value );
            throw new ParameterException(
sb.toString() );
        }

        ResultList list = new ResultListBase
        (

            Access.findByProperty( this,property,value
)

        );
        list.setLegend( property,value );

        return new ProcessResultBase( list );

   } // end execute

} // End FindEditorData
  


--- Caroline Jen <ji...@yahoo.com> wrote:
> I want to pass two hidden fields; username and
> keyName
> from a JSP via a SUBMIT button:
> 
> <req:isUserInRole role="editor">
> <html:form action="/find/Category">
> <% String username = request.getRemoteUser();%>
> <html:hidden property="keyName"
> value="journal_category"/>
> <html:hidden property="username"
> value="<%=username%>"/>
> <html:submit>View Articles</html:submit>
> </html:form>
> </req:isUserInRole>
> 
> and an action mapping:
> 
>     <action
>         roles="editor"
>         path="/find/Category"
>        
> type="org.apache.struts.scaffold.ProcessAction"
>        
>
parameter="org.apache.artimus.article.FindEditorData"
>         name="articleForm"
>         scope="request"
>         validate="false">
>        <forward
>             name="success"
>             path=".article.Result"/>
>     </action>
> 
> How come the username is not passed to the FindEditorData.java while 
> the keyName is successfully
> passed.  In the browser, I got:
> 
> name=null; kn=journal_category; kv=null
> 
> The code of my FindEditorData is shown below:
> 
> public final class FindEditorData extends Bean
> {
>    public Object execute() throws Exception
>    {
> 
>    // Obtain username 
>    String username = getUsername();
>       
>    EditorService service = new EditorService();
>    String value = service.findEditorData( username
> );
> 
>    String property = getKeyName();
>         
>         if (( null==property ) || ( null==value )) 
>         {
>             StringBuffer sb = new StringBuffer();
>             sb.append( "name=" );
>             sb.append( username );
>             sb.append( "; kn=" );
>             sb.append( property );
>             sb.append( "; kv=" );
>             sb.append( value );
>             throw new ParameterException(
> sb.toString() );
>         }
> 
>         ResultList list = new ResultListBase
>         (
> 
>             Access.findByProperty(
> this,property,value
> )
> 
>         );
>         list.setLegend( property,value );
> 
>         return new ProcessResultBase( list );
> 
>    } // end execute
> 
> } // End FindEditorData
> 
> 
> 
> __________________________________
> Do you Yahoo!?
> New Yahoo! Photos - easier uploading and sharing. 
> http://photos.yahoo.com/
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> struts-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.com/

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

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


Re: Clearing all fields or resetting the form to original state

Posted by Shakti <sh...@hotmail.com>.
For resetting to the original value u can use reset() method
and for clearing the fields I think  javascript is the best option ..
cheers ..
Shakti

----- Original Message -----
From: "vasudevrao gupta" <va...@wipro.com>
To: "'Struts Users Mailing List'" <st...@jakarta.apache.org>
Sent: Tuesday, December 09, 2003 11:57 AM
Subject: Clearing all fields or resetting the form to original state


>
>
> Is there any option in struts to reset the screen to the initial state
> on click of a button and also
> clearing all the fields on the screen on click of button?
>
> Regards
> vasudevRao Gupta
>
>
> Confidentiality Notice
>
> The information contained in this electronic message and any attachments
to this message are intended
> for the exclusive use of the addressee(s) and may contain confidential or
privileged information. If
> you are not the intended recipient, please notify the sender at Wipro or
Mailadmin@wipro.com immediately
> and destroy all copies of this message and any attachments.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>

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


Re: Clearing all fields or resetting the form to original state

Posted by Raj A <ra...@yahoo.com>.
What exactly u want to know? 
Do u think this question has anything to do with Struts?
Before posting such questions it would be better if people use a minimum Google search.
 
 
Just FYI
use   <input type="reset" value="Reset!"> 
to achieve what u want. This is a html tag which needs to be placed inside a html form.
 
Thanks
Rajesh

vasudevrao gupta <va...@wipro.com> wrote:


Is there any option in struts to reset the screen to the initial state
on click of a button and also
clearing all the fields on the screen on click of button?

Regards
vasudevRao Gupta


Confidentiality Notice 

The information contained in this electronic message and any attachments to this message are intended
for the exclusive use of the addressee(s) and may contain confidential or privileged information. If
you are not the intended recipient, please notify the sender at Wipro or Mailadmin@wipro.com immediately
and destroy all copies of this message and any attachments.

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

---------------------------------
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing

Clearing all fields or resetting the form to original state

Posted by vasudevrao gupta <va...@wipro.com>.

Is there any option in struts to reset the screen to the initial state
on click of a button and also
clearing all the fields on the screen on click of button?

Regards
vasudevRao Gupta


Confidentiality Notice 

The information contained in this electronic message and any attachments to this message are intended
for the exclusive use of the addressee(s) and may contain confidential or privileged information. If
you are not the intended recipient, please notify the sender at Wipro or Mailadmin@wipro.com immediately
and destroy all copies of this message and any attachments.

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


RE: Please Help! Unable to Pass A Hidden Field To scaffold.Proces sAction

Posted by Richard Yee <ry...@cruzio.com>.
Caroline,
What is the return value of getRemoteUser() ?

-Richard

At 07:38 PM 12/8/2003, you wrote:
>I must pass the result of request.getRemoteUser()
>because it is a "Java class" that "receives" the
>hidden field.  If you read my code carefully, you will
>see that FindEditorData.java is a Java class and I
>cannot use 'request' or 'session' in a Java class.  It
>takes a servlet or a class extends Action to use
>'request' or 'session'.
>
>But, this class is of ProcessAction type defined in
>the struts-config.xml:
>
>     <action
>         roles="editor"
>         path="/find/Category"
>
>type="org.apache.struts.scaffold.ProcessAction"
>
>parameter="org.apache.artimus.article.FindEditorData"
>         name="articleForm"
>         scope="request"
>         validate="false">
>        <forward
>             name="success"
>             path=".article.Result"/>
>     </action>
>
>And, it is easy to see that I use container-managed
>authentication.  In my JSP, there is <req:isUserInRole
>role="editor"> before reaching <% String
>username=request.getRemoteUser(); %> Again, I have
>provided my code:
><req:isUserInRole role="editor">
><% String username = request.getRemoteUser(); %> 
>value="journal_category"/> value="<%=username%>"/> View Articles --- 
>Richard Yee wrote: > Caroline, > Why are you passing the result of > 
>request.getRemoteUser() in a hidden > variable anyway since it is 
>available as part of the > HttpRequest and thus > will be available in the 
>action class? > > -Richard > > At 02:55 PM 12/8/2003, you wrote: > >I pass 
>two hidden fields: username and keyName at > the > >same time. The keyName 
>is passed and with the > correct > >value in it. The username is passed 
>but its value > >turns out to be a null. > > > >It is impossible for 
>request.getRemoteUser(); in my > >JSP returning a null. (see code below) 
>Before it > >reaches request.getRemoteUser(); the user has > 
>already > >been successfully logged in with a valid name. > > > > > ><% 
>String username = request.getRemoteUser();%> > 
>value="journal_category"/> > >value="<%=username%>"/> View Articles > >--- 
>"Yee, Richard K,,DMDCWEST" wrote: > Caroline, > > Are you 
>having > >problems with the username or the > keyName hidden > variable? 
>If > it is > >the username, then I'd suspect that > > 
>request.getRemoteUser() in your > > >JSP is returning null. > > 
>Regards, > > Richard > > > -----Original > >Message----- > From: Caroline 
>Jen > [mailto:jiapei_jen@yahoo.com] > Sent: > >Monday, December 08, 2003 
>1:32 PM > To: Struts > Users Mailing List > > >Subject: Re: Please Help! 
>Unable to Pass A Hidden > > Field To > > >scaffold.ProcessAction > > > I 
>did not mess up > lowercase and uppercase of > >the > hidden field I want 
>to pass from my JSP to > the > > >scaffold.ProcessAction. If > it had been 
>the > lowercase/uppercase problem, > >I would > have gotten a message > 
>saying that the > variable could not be > >recognized. > > I pass two 
>hidden fields at the > same time. One of > them > >is successfully passed 
>with correct value. The > > other is passed but its > >value shows a 
>'null' in the > > scaffold.ProcessAction. > What could go > >wrong? Let me 
>show my code again: > > Two hidden > fields: username and > >keyName are 
>passed > from a JSP via a SUBMIT > button: > > > > <% String > >username = 
>request.getRemoteUser();%> > > 
>value="journal_category"/> > > >value="<%=username%>"/> > View 
>Articles > > > > and > an action mapping: > > > >roles="editor" > 
>path="/find/Category" > > > >type="org.apache.struts.scaffold.ProcessAction 
>" > > > > >parameter="org.apache.artimus.article.FindEditorData" > > > >nam 
>e="articleForm" > scope="request" > > 
>validate="false"> > > >name="success" > path=".article.Result"/> > > > 
>The > value of the > >'username' is found to be a 'null' > in > the > 
>FindEditorData.java while > >the value of keyName > is successfully > 
>retrieved. > In the browser, I > >got: > > name=null; kn=journal_category; 
>kv=null > > > The code of my > >FindEditorData is shown below: > > public 
>final > class FindEditorData > >extends Bean > { > public Object execute() 
>throws > Exception > { > > // > >Obtain username > String username = 
>getUsername(); > > > EditorService > >service = new EditorService(); > 
>String value = > service.findEditorData( > >username > ); > > String 
>property = getKeyName(); > > > if (( null==property > >) || ( null==value 
>)) > { > StringBuffer sb = new > StringBuffer(); > > >sb.append( "name=" 
>); > sb.append( username ); > > sb.append( "; kn=" ); > > >sb.append( 
>property ); > sb.append( "; kv=" ); > > sb.append( value ); > > >throw new 
>ParameterException( > sb.toString() ); > > } > > ResultList list = > >new 
>ResultListBase > ( > > Access.findByProperty( > > 
>this,property,value > > >) > > ); > list.setLegend( property,value 
>); > > > return new > >ProcessResultBase( list ); > > } // end 
>execute > > > } // End > >FindEditorData > > > > --- Caroline Jen 
>wrote: > > > I want to pass two > >hidden fields; username and > > 
>keyName > > from a > JSP via a SUBMIT > >button: > > > > > > > > <% String 
>username = > >request.getRemoteUser();%> > > > > 
>value="journal_category"/> > > > > >value="<%=username%>"/> > > View 
>Articles > > > > > > > > > and an action > >mapping: > > > > > 
>roles="editor" > > > 
>path="/find/Category" > > > > > >type="org.apache.struts.scaffold.ProcessAc 
>tion" > > > > > > > >parameter="org.apache.artimus.article.FindEditorData"  
> > > > > >name="articleForm" > > scope="request" > > > 
>validate="false"> > > > > >name="success" > > 
>path=".article.Result"/> > > > > > > > How come the > >username is not 
>passed to the > FindEditorData.java > while > > the keyName > >is 
>successfully > > passed. In the browser, I got: > > > > > 
>name=null; > >kn=journal_category; kv=null > > > > The code of my > 
>FindEditorData is > >shown below: > > > > public final class > 
>FindEditorData extends Bean > > > >{ > > public Object execute() throws 
>Exception > > > { > > > > // Obtain > >username > > String username = 
>getUsername(); > > > > > EditorService > >service = new 
>EditorService(); > > String value = > 
>service.findEditorData( > >username > > ); > > > > String property = > 
>getKeyName(); > > > > if (( > >null==property ) || ( null==value )) > > > 
>{ > > > StringBuffer sb = new > >StringBuffer(); > > sb.append( "name=" 
>); > > > sb.append( username ); > > > >sb.append( "; kn=" ); > > 
>sb.append( property ); > > > sb.append( "; kv=" > >); > > sb.append( value 
>); > > throw new > ParameterException( > > > >sb.toString() ); > > 
>} > > > > ResultList list = > new ResultListBase > > > >( > > > > 
>Access.findByProperty( > > > this,property,value > > ) > > > > > >); > > 
>list.setLegend( property,value ); > > > > > return 
>new > >ProcessResultBase( list ); > === message truncated > 
>=== > >__________________________________ Do you Yahoo!? > New Yahoo! 
>Photos - > >easier uploading and sharing. > 
>http://photos.yahoo.com/ > >----------------------------------------------- 
>---------------------- > To > >unsubscribe, e-mail: > 
>struts-user-unsubscribe@jakarta.apache.org For > >additional commands, 
>e-mail: > struts-user-help@jakarta.apache.org > > > > 
>--------------------------------------------------------------------- > To 
>unsubscribe, e-mail: > struts-user-unsubscribe@jakarta.apache.org > For 
>additional commands, e-mail: > struts-user-help@jakarta.apache.org > 
>__________________________________ Do you Yahoo!? New Yahoo! Photos - 
>easier uploading and sharing. http://photos.yahoo.com/ 
>--------------------------------------------------------------------- To 
>unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org For 
>additional commands, e-mail: struts-user-help@jakarta.apache.org


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


RE: Please Help! Unable to Pass A Hidden Field To scaffold.Proces sAction

Posted by Caroline Jen <ji...@yahoo.com>.
I must pass the result of request.getRemoteUser()
because it is a "Java class" that "receives" the
hidden field.  If you read my code carefully, you will
see that FindEditorData.java is a Java class and I
cannot use 'request' or 'session' in a Java class.  It
takes a servlet or a class extends Action to use
'request' or 'session'.

But, this class is of ProcessAction type defined in
the struts-config.xml:

    <action
        roles="editor"
        path="/find/Category"
       
type="org.apache.struts.scaffold.ProcessAction"
       
parameter="org.apache.artimus.article.FindEditorData"
        name="articleForm"
        scope="request"
        validate="false">
       <forward
            name="success"
            path=".article.Result"/>
    </action>

And, it is easy to see that I use container-managed
authentication.  In my JSP, there is <req:isUserInRole
role="editor"> before reaching <% String
username=request.getRemoteUser(); %> Again, I have
provided my code:
<req:isUserInRole role="editor">
<html:form action="/find/Category">
<% String username = request.getRemoteUser(); %>
<html:hidden property="keyName"
value="journal_category"/>
<html:hidden property="username"
value="<%=username%>"/>
<html:submit>View Articles</html:submit>
</html:form>
</req:isUserInRole>

--- Richard Yee <ry...@cruzio.com> wrote:
> Caroline,
> Why are you passing the result of
> request.getRemoteUser() in a hidden 
> variable anyway since it is available as part of the
> HttpRequest and thus 
> will be available in the action class?
> 
> -Richard
> 
> At 02:55 PM 12/8/2003, you wrote:
> >I pass two hidden fields: username and keyName at
> the
> >same time.  The keyName is passed and with the
> correct
> >value in it.  The username is passed but its value
> >turns out to be a null.
> >
> >It is impossible for request.getRemoteUser(); in my
> >JSP returning a null.  (see code below) Before it
> >reaches request.getRemoteUser(); the user has
> already
> >been successfully logged in with a valid name.
> >
> ><req:isUserInRole role="editor">
> ><% String username = request.getRemoteUser();%>
> value="journal_category"/> 
> >value="<%=username%>"/> View Articles
> >--- "Yee, Richard K,,DMDCWEST" wrote: > Caroline, >
> Are you having 
> >problems with the username or the > keyName hidden
> variable? If > it is 
> >the username, then I'd suspect that >
> request.getRemoteUser() in your > 
> >JSP is returning null. > > Regards, > > Richard > >
> -----Original 
> >Message----- > From: Caroline Jen
> [mailto:jiapei_jen@yahoo.com] > Sent: 
> >Monday, December 08, 2003 1:32 PM > To: Struts
> Users Mailing List > 
> >Subject: Re: Please Help! Unable to Pass A Hidden >
> Field To > 
> >scaffold.ProcessAction > > > I did not mess up
> lowercase and uppercase of 
> >the > hidden field I want to pass from my JSP to
> the > 
> >scaffold.ProcessAction. If > it had been the
> lowercase/uppercase problem, 
> >I would > have gotten a message > saying that the
> variable could not be 
> >recognized. > > I pass two hidden fields at the
> same time. One of > them 
> >is successfully passed with correct value. The >
> other is passed but its 
> >value shows a 'null' in the >
> scaffold.ProcessAction. > What could go 
> >wrong? Let me show my code again: > > Two hidden
> fields: username and 
> >keyName are passed > from a JSP via a SUBMIT
> button: > > > > <% String 
> >username = request.getRemoteUser();%> >
> value="journal_category"/> > 
> >value="<%=username%>"/> > View Articles > > > > and
> an action mapping: > > 
> >roles="editor" > path="/find/Category" > > 
> >type="org.apache.struts.scaffold.ProcessAction" > >
> 
>
>parameter="org.apache.artimus.article.FindEditorData"
> > 
> >name="articleForm" > scope="request" >
> validate="false"> > 
> >name="success" > path=".article.Result"/> > > > The
> value of the 
> >'username' is found to be a 'null' > in > the
> FindEditorData.java while 
> >the value of keyName > is successfully > retrieved.
> In the browser, I 
> >got: > > name=null; kn=journal_category; kv=null >
> > The code of my 
> >FindEditorData is shown below: > > public final
> class FindEditorData 
> >extends Bean > { > public Object execute() throws
> Exception > { > > // 
> >Obtain username > String username = getUsername();
> > > EditorService 
> >service = new EditorService(); > String value =
> service.findEditorData( 
> >username > ); > > String property = getKeyName(); >
> > if (( null==property 
> >) || ( null==value )) > { > StringBuffer sb = new
> StringBuffer(); > 
> >sb.append( "name=" ); > sb.append( username ); >
> sb.append( "; kn=" ); > 
> >sb.append( property ); > sb.append( "; kv=" ); >
> sb.append( value ); > 
> >throw new ParameterException( > sb.toString() ); >
> } > > ResultList list = 
> >new ResultListBase > ( > > Access.findByProperty( >
> this,property,value > 
> >) > > ); > list.setLegend( property,value ); > >
> return new 
> >ProcessResultBase( list ); > > } // end execute > >
> } // End 
> >FindEditorData > > > > --- Caroline Jen wrote: > >
> I want to pass two 
> >hidden fields; username and > > keyName > > from a
> JSP via a SUBMIT 
> >button: > > > > > > > > <% String username = 
> >request.getRemoteUser();%> > > >
> value="journal_category"/> > > > 
> >value="<%=username%>"/> > > View Articles > > > > >
> > > > and an action 
> >mapping: > > > > > roles="editor" > >
> path="/find/Category" > > > > 
> >type="org.apache.struts.scaffold.ProcessAction" > >
> > > > 
>
>parameter="org.apache.artimus.article.FindEditorData"
> > > 
> >name="articleForm" > > scope="request" > >
> validate="false"> > > > 
> >name="success" > > path=".article.Result"/> > > > >
> > > How come the 
> >username is not passed to the > FindEditorData.java
> while > > the keyName 
> >is successfully > > passed. In the browser, I got:
> > > > > name=null; 
> >kn=journal_category; kv=null > > > > The code of my
> FindEditorData is 
> >shown below: > > > > public final class
> FindEditorData extends Bean > > 
> >{ > > public Object execute() throws Exception > >
> { > > > > // Obtain 
> >username > > String username = getUsername(); > > >
> > EditorService 
> >service = new EditorService(); > > String value =
> service.findEditorData( 
> >username > > ); > > > > String property =
> getKeyName(); > > > > if (( 
> >null==property ) || ( null==value )) > > > { > >
> StringBuffer sb = new 
> >StringBuffer(); > > sb.append( "name=" ); > >
> sb.append( username ); > > 
> >sb.append( "; kn=" ); > > sb.append( property ); >
> > sb.append( "; kv=" 
> >); > > sb.append( value ); > > throw new
> ParameterException( > > 
> >sb.toString() ); > > } > > > > ResultList list =
> new ResultListBase > > 
> >( > > > > Access.findByProperty( > >
> this,property,value > > ) > > > > 
> >); > > list.setLegend( property,value ); > > > >
> return new 
> >ProcessResultBase( list ); > === message truncated
> === 
> >__________________________________ Do you Yahoo!?
> New Yahoo! Photos - 
> >easier uploading and sharing.
> http://photos.yahoo.com/ 
>
>---------------------------------------------------------------------
> To 
> >unsubscribe, e-mail:
> struts-user-unsubscribe@jakarta.apache.org For 
> >additional commands, e-mail:
> struts-user-help@jakarta.apache.org
> 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> struts-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/

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


RE: Please Help! Unable to Pass A Hidden Field To scaffold.Proces sAction

Posted by Richard Yee <ry...@cruzio.com>.
Caroline,
Why are you passing the result of request.getRemoteUser() in a hidden 
variable anyway since it is available as part of the HttpRequest and thus 
will be available in the action class?

-Richard

At 02:55 PM 12/8/2003, you wrote:
>I pass two hidden fields: username and keyName at the
>same time.  The keyName is passed and with the correct
>value in it.  The username is passed but its value
>turns out to be a null.
>
>It is impossible for request.getRemoteUser(); in my
>JSP returning a null.  (see code below) Before it
>reaches request.getRemoteUser(); the user has already
>been successfully logged in with a valid name.
>
><req:isUserInRole role="editor">
><% String username = request.getRemoteUser();%> value="journal_category"/> 
>value="<%=username%>"/> View Articles
>--- "Yee, Richard K,,DMDCWEST" wrote: > Caroline, > Are you having 
>problems with the username or the > keyName hidden variable? If > it is 
>the username, then I'd suspect that > request.getRemoteUser() in your > 
>JSP is returning null. > > Regards, > > Richard > > -----Original 
>Message----- > From: Caroline Jen [mailto:jiapei_jen@yahoo.com] > Sent: 
>Monday, December 08, 2003 1:32 PM > To: Struts Users Mailing List > 
>Subject: Re: Please Help! Unable to Pass A Hidden > Field To > 
>scaffold.ProcessAction > > > I did not mess up lowercase and uppercase of 
>the > hidden field I want to pass from my JSP to the > 
>scaffold.ProcessAction. If > it had been the lowercase/uppercase problem, 
>I would > have gotten a message > saying that the variable could not be 
>recognized. > > I pass two hidden fields at the same time. One of > them 
>is successfully passed with correct value. The > other is passed but its 
>value shows a 'null' in the > scaffold.ProcessAction. > What could go 
>wrong? Let me show my code again: > > Two hidden fields: username and 
>keyName are passed > from a JSP via a SUBMIT button: > > > > <% String 
>username = request.getRemoteUser();%> > value="journal_category"/> > 
>value="<%=username%>"/> > View Articles > > > > and an action mapping: > > 
>roles="editor" > path="/find/Category" > > 
>type="org.apache.struts.scaffold.ProcessAction" > > 
>parameter="org.apache.artimus.article.FindEditorData" > 
>name="articleForm" > scope="request" > validate="false"> > 
>name="success" > path=".article.Result"/> > > > The value of the 
>'username' is found to be a 'null' > in > the FindEditorData.java while 
>the value of keyName > is successfully > retrieved. In the browser, I 
>got: > > name=null; kn=journal_category; kv=null > > The code of my 
>FindEditorData is shown below: > > public final class FindEditorData 
>extends Bean > { > public Object execute() throws Exception > { > > // 
>Obtain username > String username = getUsername(); > > EditorService 
>service = new EditorService(); > String value = service.findEditorData( 
>username > ); > > String property = getKeyName(); > > if (( null==property 
>) || ( null==value )) > { > StringBuffer sb = new StringBuffer(); > 
>sb.append( "name=" ); > sb.append( username ); > sb.append( "; kn=" ); > 
>sb.append( property ); > sb.append( "; kv=" ); > sb.append( value ); > 
>throw new ParameterException( > sb.toString() ); > } > > ResultList list = 
>new ResultListBase > ( > > Access.findByProperty( > this,property,value > 
>) > > ); > list.setLegend( property,value ); > > return new 
>ProcessResultBase( list ); > > } // end execute > > } // End 
>FindEditorData > > > > --- Caroline Jen wrote: > > I want to pass two 
>hidden fields; username and > > keyName > > from a JSP via a SUBMIT 
>button: > > > > > > > > <% String username = 
>request.getRemoteUser();%> > > > value="journal_category"/> > > > 
>value="<%=username%>"/> > > View Articles > > > > > > > > and an action 
>mapping: > > > > > roles="editor" > > path="/find/Category" > > > > 
>type="org.apache.struts.scaffold.ProcessAction" > > > > > 
>parameter="org.apache.artimus.article.FindEditorData" > > 
>name="articleForm" > > scope="request" > > validate="false"> > > > 
>name="success" > > path=".article.Result"/> > > > > > > How come the 
>username is not passed to the > FindEditorData.java while > > the keyName 
>is successfully > > passed. In the browser, I got: > > > > name=null; 
>kn=journal_category; kv=null > > > > The code of my FindEditorData is 
>shown below: > > > > public final class FindEditorData extends Bean > > 
>{ > > public Object execute() throws Exception > > { > > > > // Obtain 
>username > > String username = getUsername(); > > > > EditorService 
>service = new EditorService(); > > String value = service.findEditorData( 
>username > > ); > > > > String property = getKeyName(); > > > > if (( 
>null==property ) || ( null==value )) > > > { > > StringBuffer sb = new 
>StringBuffer(); > > sb.append( "name=" ); > > sb.append( username ); > > 
>sb.append( "; kn=" ); > > sb.append( property ); > > sb.append( "; kv=" 
>); > > sb.append( value ); > > throw new ParameterException( > > 
>sb.toString() ); > > } > > > > ResultList list = new ResultListBase > > 
>( > > > > Access.findByProperty( > > this,property,value > > ) > > > > 
>); > > list.setLegend( property,value ); > > > > return new 
>ProcessResultBase( list ); > === message truncated === 
>__________________________________ Do you Yahoo!? New Yahoo! Photos - 
>easier uploading and sharing. http://photos.yahoo.com/ 
>--------------------------------------------------------------------- To 
>unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org For 
>additional commands, e-mail: struts-user-help@jakarta.apache.org



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


Re: Please Help! Unable to Pass A Hidden Field To scaffold.Proces sAction

Posted by Adam Hardy <ah...@cyberspaceroad.com>.
Rats, the thread broke, hence my other reply. Like everyone says, you 
need to check the return value of getRemoteUser() - try looking at the 
value of the hidden field in the HTML via IE's 'Show page source'.

On 12/08/2003 11:55 PM Caroline Jen wrote:
> I pass two hidden fields: username and keyName at the
> same time.  The keyName is passed and with the correct
> value in it.  The username is passed but its value
> turns out to be a null.
> 
> It is impossible for request.getRemoteUser(); in my
> JSP returning a null.  (see code below) Before it
> reaches request.getRemoteUser(); the user has already
> been successfully logged in with a valid name.
> 
> <req:isUserInRole role="editor">
> <html:form action="/find/Category">
> <TR>
> <TD class="option">
> <% String username = request.getRemoteUser();%>
> <html:hidden property="keyName"
> value="journal_category"/>
> <html:hidden property="username"
> value="<%=username%>"/>
> <html:submit>View Articles</html:submit>
> </TD>
> </TR>
> </html:form>
> </req:isUserInRole>
> --- "Yee, Richard K,,DMDCWEST"
> <Ye...@osd.pentagon.mil> wrote:
> 
>>Caroline,
>>Are you having problems with the username or the
>>keyName hidden variable? If
>>it is the username, then I'd suspect that
>>request.getRemoteUser() in your
>>JSP is returning null.
>>
>>Regards,
>>
>>Richard
>>
>>-----Original Message-----
>>From: Caroline Jen [mailto:jiapei_jen@yahoo.com] 
>>Sent: Monday, December 08, 2003 1:32 PM
>>To: Struts Users Mailing List
>>Subject: Re: Please Help! Unable to Pass A Hidden
>>Field To
>>scaffold.ProcessAction
>>
>>
>>I did not mess up lowercase and uppercase of the
>>hidden field I want to pass from my JSP to the
>>scaffold.ProcessAction.  If
>>it had been the lowercase/uppercase problem, I would
>>have gotten a message
>>saying that the variable could not be recognized.  
>>
>>I pass two hidden fields at the same time.  One of
>>them is successfully passed with correct value.  The
>>other is passed but its value shows a 'null' in the
>>scaffold.ProcessAction.
>>What could go wrong?  Let me show my code again:
>>
>>Two hidden fields: username and keyName are passed 
>>from a JSP via a SUBMIT button:
>>
>><req:isUserInRole role="editor">
>><html:form action="/find/Category">
>><% String username = request.getRemoteUser();%>
>><html:hidden property="keyName"
>>value="journal_category"/>
>><html:hidden property="username"
>>value="<%=username%>"/>
>><html:submit>View Articles</html:submit>
>></html:form>
>></req:isUserInRole>
>>
>>and an action mapping:
>>
>>    <action
>>        roles="editor"
>>        path="/find/Category"
>>       
>>type="org.apache.struts.scaffold.ProcessAction"
>>       
>>
> 
> parameter="org.apache.artimus.article.FindEditorData"
> 
>>        name="articleForm"
>>        scope="request"
>>        validate="false">
>>       <forward
>>            name="success"
>>            path=".article.Result"/>
>>    </action>
>>
>>The value of the 'username' is found to be a 'null'
>>in
>>the FindEditorData.java while the value of keyName
>>is successfully
>>retrieved.  In the browser, I got:
>>
>>name=null; kn=journal_category; kv=null 
>>
>>The code of my FindEditorData is shown below:
>>
>>public final class FindEditorData extends Bean
>>{
>>   public Object execute() throws Exception
>>   {
>>
>>   // Obtain username 
>>   String username = getUsername();
>>      
>>   EditorService service = new EditorService();
>>   String value = service.findEditorData( username
>>);
>>
>>   String property = getKeyName();
>>        
>>        if (( null==property ) || ( null==value )) 
>>        {
>>            StringBuffer sb = new StringBuffer();
>>            sb.append( "name=" );
>>            sb.append( username );
>>            sb.append( "; kn=" );
>>            sb.append( property );
>>            sb.append( "; kv=" );
>>            sb.append( value );
>>            throw new ParameterException(
>>sb.toString() );
>>        }
>>
>>        ResultList list = new ResultListBase
>>        (
>>
>>            Access.findByProperty(
>>this,property,value
>>)
>>
>>        );
>>        list.setLegend( property,value );
>>
>>        return new ProcessResultBase( list );
>>
>>   } // end execute
>>
>>} // End FindEditorData
>>  
>>
>>
>>--- Caroline Jen <ji...@yahoo.com> wrote:
>>
>>>I want to pass two hidden fields; username and
>>>keyName
>>>from a JSP via a SUBMIT button:
>>>
>>><req:isUserInRole role="editor">
>>><html:form action="/find/Category">
>>><% String username = request.getRemoteUser();%>
>>><html:hidden property="keyName"
>>>value="journal_category"/>
>>><html:hidden property="username"
>>>value="<%=username%>"/>
>>><html:submit>View Articles</html:submit>
>>></html:form>
>>></req:isUserInRole>
>>>
>>>and an action mapping:
>>>
>>>    <action
>>>        roles="editor"
>>>        path="/find/Category"
>>>       
>>>type="org.apache.struts.scaffold.ProcessAction"
>>>       
>>>
>>
> parameter="org.apache.artimus.article.FindEditorData"
> 
>>>        name="articleForm"
>>>        scope="request"
>>>        validate="false">
>>>       <forward
>>>            name="success"
>>>            path=".article.Result"/>
>>>    </action>
>>>
>>>How come the username is not passed to the
>>
>>FindEditorData.java while 
>>
>>>the keyName is successfully
>>>passed.  In the browser, I got:
>>>
>>>name=null; kn=journal_category; kv=null
>>>
>>>The code of my FindEditorData is shown below:
>>>
>>>public final class FindEditorData extends Bean
>>>{
>>>   public Object execute() throws Exception
>>>   {
>>>
>>>   // Obtain username 
>>>   String username = getUsername();
>>>      
>>>   EditorService service = new EditorService();
>>>   String value = service.findEditorData( username
>>>);
>>>
>>>   String property = getKeyName();
>>>        
>>>        if (( null==property ) || ( null==value ))
>>
>>>        {
>>>            StringBuffer sb = new StringBuffer();
>>>            sb.append( "name=" );
>>>            sb.append( username );
>>>            sb.append( "; kn=" );
>>>            sb.append( property );
>>>            sb.append( "; kv=" );
>>>            sb.append( value );
>>>            throw new ParameterException(
>>>sb.toString() );
>>>        }
>>>
>>>        ResultList list = new ResultListBase
>>>        (
>>>
>>>            Access.findByProperty(
>>>this,property,value
>>>)
>>>
>>>        );
>>>        list.setLegend( property,value );
>>>
>>>        return new ProcessResultBase( list );
>>
> === message truncated ===
> 
> 
> __________________________________
> Do you Yahoo!?
> New Yahoo! Photos - easier uploading and sharing.
> http://photos.yahoo.com/
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 
> 


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


RE: Please Help! Unable to Pass A Hidden Field To scaffold.Proces sAction

Posted by Caroline Jen <ji...@yahoo.com>.
I pass two hidden fields: username and keyName at the
same time.  The keyName is passed and with the correct
value in it.  The username is passed but its value
turns out to be a null.

It is impossible for request.getRemoteUser(); in my
JSP returning a null.  (see code below) Before it
reaches request.getRemoteUser(); the user has already
been successfully logged in with a valid name.

<req:isUserInRole role="editor">
<html:form action="/find/Category">
<TR>
<TD class="option">
<% String username = request.getRemoteUser();%>
<html:hidden property="keyName"
value="journal_category"/>
<html:hidden property="username"
value="<%=username%>"/>
<html:submit>View Articles</html:submit>
</TD>
</TR>
</html:form>
</req:isUserInRole>
--- "Yee, Richard K,,DMDCWEST"
<Ye...@osd.pentagon.mil> wrote:
> Caroline,
> Are you having problems with the username or the
> keyName hidden variable? If
> it is the username, then I'd suspect that
> request.getRemoteUser() in your
> JSP is returning null.
> 
> Regards,
> 
> Richard
> 
> -----Original Message-----
> From: Caroline Jen [mailto:jiapei_jen@yahoo.com] 
> Sent: Monday, December 08, 2003 1:32 PM
> To: Struts Users Mailing List
> Subject: Re: Please Help! Unable to Pass A Hidden
> Field To
> scaffold.ProcessAction
> 
> 
> I did not mess up lowercase and uppercase of the
> hidden field I want to pass from my JSP to the
> scaffold.ProcessAction.  If
> it had been the lowercase/uppercase problem, I would
> have gotten a message
> saying that the variable could not be recognized.  
> 
> I pass two hidden fields at the same time.  One of
> them is successfully passed with correct value.  The
> other is passed but its value shows a 'null' in the
> scaffold.ProcessAction.
> What could go wrong?  Let me show my code again:
> 
> Two hidden fields: username and keyName are passed 
> from a JSP via a SUBMIT button:
> 
> <req:isUserInRole role="editor">
> <html:form action="/find/Category">
> <% String username = request.getRemoteUser();%>
> <html:hidden property="keyName"
> value="journal_category"/>
> <html:hidden property="username"
> value="<%=username%>"/>
> <html:submit>View Articles</html:submit>
> </html:form>
> </req:isUserInRole>
> 
> and an action mapping:
> 
>     <action
>         roles="editor"
>         path="/find/Category"
>        
> type="org.apache.struts.scaffold.ProcessAction"
>        
>
parameter="org.apache.artimus.article.FindEditorData"
>         name="articleForm"
>         scope="request"
>         validate="false">
>        <forward
>             name="success"
>             path=".article.Result"/>
>     </action>
> 
> The value of the 'username' is found to be a 'null'
> in
> the FindEditorData.java while the value of keyName
> is successfully
> retrieved.  In the browser, I got:
> 
> name=null; kn=journal_category; kv=null 
> 
> The code of my FindEditorData is shown below:
> 
> public final class FindEditorData extends Bean
> {
>    public Object execute() throws Exception
>    {
> 
>    // Obtain username 
>    String username = getUsername();
>       
>    EditorService service = new EditorService();
>    String value = service.findEditorData( username
> );
> 
>    String property = getKeyName();
>         
>         if (( null==property ) || ( null==value )) 
>         {
>             StringBuffer sb = new StringBuffer();
>             sb.append( "name=" );
>             sb.append( username );
>             sb.append( "; kn=" );
>             sb.append( property );
>             sb.append( "; kv=" );
>             sb.append( value );
>             throw new ParameterException(
> sb.toString() );
>         }
> 
>         ResultList list = new ResultListBase
>         (
> 
>             Access.findByProperty(
> this,property,value
> )
> 
>         );
>         list.setLegend( property,value );
> 
>         return new ProcessResultBase( list );
> 
>    } // end execute
> 
> } // End FindEditorData
>   
> 
> 
> --- Caroline Jen <ji...@yahoo.com> wrote:
> > I want to pass two hidden fields; username and
> > keyName
> > from a JSP via a SUBMIT button:
> > 
> > <req:isUserInRole role="editor">
> > <html:form action="/find/Category">
> > <% String username = request.getRemoteUser();%>
> > <html:hidden property="keyName"
> > value="journal_category"/>
> > <html:hidden property="username"
> > value="<%=username%>"/>
> > <html:submit>View Articles</html:submit>
> > </html:form>
> > </req:isUserInRole>
> > 
> > and an action mapping:
> > 
> >     <action
> >         roles="editor"
> >         path="/find/Category"
> >        
> > type="org.apache.struts.scaffold.ProcessAction"
> >        
> >
>
parameter="org.apache.artimus.article.FindEditorData"
> >         name="articleForm"
> >         scope="request"
> >         validate="false">
> >        <forward
> >             name="success"
> >             path=".article.Result"/>
> >     </action>
> > 
> > How come the username is not passed to the
> FindEditorData.java while 
> > the keyName is successfully
> > passed.  In the browser, I got:
> > 
> > name=null; kn=journal_category; kv=null
> > 
> > The code of my FindEditorData is shown below:
> > 
> > public final class FindEditorData extends Bean
> > {
> >    public Object execute() throws Exception
> >    {
> > 
> >    // Obtain username 
> >    String username = getUsername();
> >       
> >    EditorService service = new EditorService();
> >    String value = service.findEditorData( username
> > );
> > 
> >    String property = getKeyName();
> >         
> >         if (( null==property ) || ( null==value ))
> 
> >         {
> >             StringBuffer sb = new StringBuffer();
> >             sb.append( "name=" );
> >             sb.append( username );
> >             sb.append( "; kn=" );
> >             sb.append( property );
> >             sb.append( "; kv=" );
> >             sb.append( value );
> >             throw new ParameterException(
> > sb.toString() );
> >         }
> > 
> >         ResultList list = new ResultListBase
> >         (
> > 
> >             Access.findByProperty(
> > this,property,value
> > )
> > 
> >         );
> >         list.setLegend( property,value );
> > 
> >         return new ProcessResultBase( list );
> 
=== message truncated ===


__________________________________
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/

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