aspose file tools*
The moose likes Struts and the fly likes How to find to which row is selected? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to find to which row is selected?" Watch "How to find to which row is selected?" New topic
Author

How to find to which row is selected?

manasa teja
Ranch Hand

Joined: May 27, 2002
Posts: 325
Hi Friends
I am displaying employee search results.
I am using logic:iterate tag to dispay the results. and pagination is also there.
The data displayed is
one radio button, emp no, emp full name , dept
so far everything is fine.
Now, the end user selects a row and will perform soem other operations like update/delete etc.
Now, When the users selects teh radio button, how to find, which row he selected.
thanks
Manasa


MT
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
give the radio buttons the appropriate values, e.g. the employee id. And then check in the Action which radio button was selected.
manasa teja
Ranch Hand

Joined: May 27, 2002
Posts: 325
Originally posted by Oliver Refle:
give the radio buttons the appropriate values, e.g. the employee id. And then check in the Action which radio button was selected.

Thnks Oliver for your reply.. I got your point.
BUt do not how to implemet it.
I will re-explain it here...
Once the last name is entered and click on search button is cliked , i am displaying following things in multiple rowws, which mates teh user's input.
I am using logic:iterate
One radiobutton EmpFull name Emp NO Dept
I understood ur point.
How Can I assign EmpNo to radio button. they are all coming from same bean

Here is my piece of code

Here only my doubt..
How can I asssign empNo to radiobutton's value attribute..
is it something liek this......
<html:radio name="element" property="selectRow" value ="<bean:write name="element" property="empNo"/> .......
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944

Here only my doubt..
How can I asssign empNo to radiobutton's value attribute..
is it something liek this......
<html:radio name="element" property="selectRow" value ="<bean:write name="element" property="empNo"/> ....... [/QB]

try

this should help you out
manasa teja
Ranch Hand

Joined: May 27, 2002
Posts: 325
Originally posted by Oliver Refle:

this should help you out


Thanks Oliver... Thats a qucihk reply!!
But, had no luck.. I tried as you suggested.. But its giving me error..
Value Attribute is mandatory for radiobutton...
manasa teja
Ranch Hand

Joined: May 27, 2002
Posts: 325
Any body has any suggestions on this...
please help
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4756
    
    7

You can define a scripting variable with bean:define
<bean:define id="currentEmpNo" name="element" property="empNo" />
<html:radio .... value="<%= currentEmpNo %>" />
See also: this thread.
[ October 24, 2003: Message edited by: Junilu Lacar ]

Junilu - [How to Ask Questions] [How to Answer Questions]
manasa teja
Ranch Hand

Joined: May 27, 2002
Posts: 325
Originally posted by Junilu Lacar:
You can define a scripting variable with bean efine
<bean efine id="currentEmpNo" name="element" property="empNo" />
<html:radio .... value="<%= currentEmpNo %>" />
See also: this thread.
[ October 24, 2003: Message edited by: Junilu Lacar ]

Oh!! Thanks Junilu... Its working .. I was actually having a lot of daoubts on this defining a scriptng varibale.. wiith this, i am a bit claear about it..
Can we decalre "type" for the scriting variable also... Like, if I want teh variable of type int, String, etc..
Thanks again.... I appreciate yoru help on this...
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4756
    
    7

Originally posted by manasa teja:

Can we decalre "type" for the scriting variable also... Like, if I want teh variable of type int, String, etc..
Thanks again.... I appreciate yoru help on this...


Yes, you can define the type. I gave you a link to the documentation for bean:define in this thread. If you have any doubts, you can always ask for clarification here but please try to go through the available documentation first--that's probably one of the best ways to show other folks your appreciation for their time and help.
manasa teja
Ranch Hand

Joined: May 27, 2002
Posts: 325
Friends
Thanks for all yur help on this..
I have one more problem.
Now that, I am displaying the radio buttons for the all search records , and I am assigning the empno/name to the radio button, when it is selected.. Its working fine
Now, my question is how to validate , whether the user really selected a row or not?
If he does not select anyrow and wants to click on Update button, Should I throw the error message " Please select the radio button to edit employee details" or Can we display the rows, with first row or last row already selected. Which one is better? how to do that??.
And we are implementing valisdation framework in our application. Will that offer any help in this regard...
Thanks
mt
sandy gupta
Ranch Hand

Joined: Jan 30, 2001
Posts: 228
<form name="/whatever">
<field property="selectedField" depends="required">
<msg name="required" key="errors.noselection"/>
<arg0 key=""/>
</field>
</form>
This put into your validation.xml will take care of the problem. If you are not using the validation framework then you could use the null check on the form bean attribute and make your own message and send the user back to the page.
HTH
Sahil


Adios
manasa teja
Ranch Hand

Joined: May 27, 2002
Posts: 325
sandy..
thanks for ur reply
I already tried that approach using validation framework, but its not working..
I think, Problem is with my form!!
INitially, there will be obnly one textbox in the form. So the user enters lastname of the employee in the textbox for saerch. Here, i am doing somevalidations like , required, mask, minlength etc. Its working fine!! So, once trhe user input is validated, it will fetch the recors , whose last name matches with teh search criteria!!
Now, I am displaying a radio button for all the rows, so atht, the user can select a rowq and click on the Update button and go to update details page!!
Here only its causing the problems!!
if i put teh validation code in the validation.xml i.e

Its giving me loty of problems. As initially, therer are no radiobiuttons in the form, and only last name and search button are there, it is tryiung to find the radiobutton( selectRow) to validate, it is throwing soe stange errors( some javascript erros liek type not found etc). Hope you all understood teh problem here!! PLease suggest me a solution..
manasa teja
Ranch Hand

Joined: May 27, 2002
Posts: 325
Any suggestions on this please.....
manasa teja
Ranch Hand

Joined: May 27, 2002
Posts: 325
Looks like, its somehwt related to this bug rteported in validator link
validator-rules.xml JavaScript fails when field not present in jsp
Any workaround for this ??
[ October 31, 2003: Message edited by: manasa teja ]
manasa teja
Ranch Hand

Joined: May 27, 2002
Posts: 325
any suggestions on this....
manasa teja
Ranch Hand

Joined: May 27, 2002
Posts: 325
Any suggestions on this please..
manasa teja
Ranch Hand

Joined: May 27, 2002
Posts: 325
please help me on ths problem..
sandy gupta
Ranch Hand

Joined: Jan 30, 2001
Posts: 228
i have done something like this in my code and it never gave me a problem so i really cannot understand what could be going wrong there, but to avoid this problem should have been really easy. Take out the validation for the radio button from the validation.xml and put it into the action class. If there is nothing selected send the user back to the input and ask him to make a selection.
Sahil
p.s: If you could explain the problem better.......
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to find to which row is selected?