Richard,
Yes, using session variable is a good alternative to around this issue. But
since I generalized & parameterize this JSP page(grid) , means this page(grid)
acts as something like a tag which can be used(or called ) several times in an
application, even in one screen. For example in one screen may exist one master
with more then one details. To represent details, I called this page(grid )
with specific parameters. So, if I use session variables to state each checkbox
in each page(grid), then I may have a fat session variables which I am try to
avoid this so far unless I have to. But your tip regards using �bitmap� to
state checkbox on each grid is a very valuable tip to avoid allocate much
resources. And I am gona use this tip If finally decided to go for session
variables to around this issue. I really appreciate for sharing me your mind.
Colin,
Using hidden input tags is what I�d like to do and unsuccessfully put my effort
on this so far. The problem on this is because of my program logic.
Let me explain more on this:
In this JSP page(grid) I named a unique name for each tag. This name is
concatenated of three parts(a digit 0/1)+(column_name)+(row no). the first
part indicate that this cell is changed or never changed (�0�:cell is never
changed �1�:cell is changed ). For example pretend the cell name located at
row=5 and column_name=�post�, server will receive the name of this cell in one
of the following model:
1- �0post5� : if this cell never changed(default).
2- �1post5� : if this cell changed at least once. (the cell name changes by
javascript onchange event)
Then servlet on the server only request for the changed-columns(columns started
with �1�). Then update the database, If founded.
Now in your suggestion I could take a placeholder hidden input tag and store
Y/N in it. The only problem here is that I don�t know how I can change the name
of that hidden field when checkbox clicked. Because the name of the hidden
field is not fixed and depended to the where is located(in grid) and created in
a loop.
Following I brought the code to show how I change the name of cells. The first
one which indicate the logic for all other tags except checkbox is ok. The
problem is the second one which I don�t know how I can change the name of
hidden field which will take the value of checkbox to the server.
1- Code to change the name of all other cells except checkbox:
<input name=�0<%=colName%><%=rowno%>� onchange=�columnChanged(this)�>
<SCRIPT>
function columnChange(field){
field.name=�1�+field.name.substring(1);
}
</SCRIPT>
2- Code to change the name of the hiddenfield for checkbox:
<input type=�checkbox� name=�� onchange=�checkboxChangeed(this)�>
<input type=�hidden� name=�0<%=colName%><%=rowno%>�>
<SCRIPT>
function checkboxChange(field){
<!--
here the name of hiddenfield must change from (here is the problem, because
field.name parameter indicates the name of checkbox, no hiddenfield )
then change the value of hiddenfield from �Y� to �N� or vise versa(this part is
ok).
-->
}
</SCRIPT>
Hope I could demonstrate my program logic clearly. I would appreacate if you
could share your mind with me to know how I could change the name of
hiddenfield when checkbox field clicked.
Regards
Ali
--- Colin Capriati <[EMAIL PROTECTED]> wrote:
> If you don't mind relying on JavaScript, you may also create a set of hidden
> INPUT controls in the HTML form that map to the same parameters as your
> checkboxes, and then use JavaScript to handle the checkbox.onchange event
> and update the appropriate hidden control. When the HTML form is submitted
> to server, you will check the values of the hidden controls and ignore the
> values submitted by the checkboxes. Depending on your situation, in
> implementing this technique you could place the checkboxes outside of the
> HTML form so they don't submit values to the server at all.
>
> Colin
>
> ----- Original Message -----
> From: "Richard Yee" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, December 14, 2001 12:05 PM
> Subject: Re: request.getParameter() question
>
>
> > Ali,
> > If you record the initial state of the checkboxes in a bitfield or other
> > datastructure in the session and then generate another bitfield of the
> > checkbox states from the request to the servlet, you can tell exactly what
> > checkboxes have been changed.
> >
> > Regards,
> >
> > Richard
> >
> >
> > At 11:55 AM 12/14/2001 -0800, you wrote:
> > >Thanks for your reply. Still need more help.
> > >
> > >Actually this a checkbox issue. I my case i believe
> > >your suggestions couldn't help me
> > >(req.getParameterNames(). Also assign default value)
> > >
> > >Let's explain more:
> > >On client: I have a JSP page like spread sheet(grid).
> > >some of the columns may be checkboxs. As you know
> > >checkbox will not pass a value to webserver when is
> > >un-checked. If any column changed, it's name will
> > >concatenated by 1. (field.name= "1"+field.name).
> > >
> > >On server: The servlet will only request for
> > >changed-columns and update database.
> > >request.getParameter("1"+col_name);
> > >
> > >This logic works good for all other tags except
> > >checkboxs. Because cannot realize the
> > >1- checkbox is never changed.
> > >2- checkbox is changed to un-check.
> > >Servlet must ignore the first case but update the
> > >database for the second case.
> > >
> > >Thanks...Ali
> > >--- Mark Galbreath <[EMAIL PROTECTED]> wrote:
> > > > Or assign the parameter a default value.
> > > >
> > > > Mark
> > > >
> > > > -----Original Message-----
> > > > From: Jeremy W. Redmond
> > > > Sent: Friday, December 14, 2001 12:31 PM
> > > >
> > > > see if it is in the enumeration
> > > > req.getParameterNames().
> > > >
> > > > -----Original Message-----
> > > >
> > > > value=request.getParameter("param_name");
> > > >
> > > > The above statement in called page will return null
> > > > in
> > > > two cases:
> > > >
> > > > 1-when the "param_name" is passed with no value
> > > > 2-when the "param_name" didn't pass at all.
> > > >
> > > > How can I differentiate these two. I mean I need to
> > > > somehow know whether
> > > > Parameter did not pass or passed with no value.
> > > >
> > > >
> >
> >___________________________________________________________________________
> > > > To unsubscribe, send email to [EMAIL PROTECTED]
> > > > and include in the body
> > > > of the message "signoff SERVLET-INTEREST".
> > > >
> > > > Archives:
> > > >
> > >http://archives.java.sun.com/archives/servlet-interest.html
> > > > Resources:
> > > >
> > >http://java.sun.com/products/servlet/external-resources.html
> > > > LISTSERV Help:
> > > > http://www.lsoft.com/manuals/user/user.html
> > > >
> > >
> > >
> > >__________________________________________________
> > >Do You Yahoo!?
> > >Check out Yahoo! Shopping and Yahoo! Auctions for all of
> > >your unique holiday gifts! Buy at http://shopping.yahoo.com
> > >or bid at http://auctions.yahoo.com
> > >
> >
> >___________________________________________________________________________
> > >To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> body
> > >of the message "signoff SERVLET-INTEREST".
> > >
> > >Archives: http://archives.java.sun.com/archives/servlet-interest.html
> > >Resources: http://java.sun.com/products/servlet/external-resources.html
> > >LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
> >
> >
> ___________________________________________________________________________
> > To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> body
> > of the message "signoff SERVLET-INTEREST".
> >
> > Archives: http://archives.java.sun.com/archives/servlet-interest.html
> > Resources: http://java.sun.com/products/servlet/external-resources.html
> > LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
> >
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
__________________________________________________
Do You Yahoo!?
Check out Yahoo! Shopping and Yahoo! Auctions for all of
your unique holiday gifts! Buy at http://shopping.yahoo.com
or bid at http://auctions.yahoo.com
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html