*
The moose likes Struts and the fly likes Problem in Creating Dynamic Link from Display Table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Problem in Creating Dynamic Link from Display Table" Watch "Problem in Creating Dynamic Link from Display Table" New topic
Author

Problem in Creating Dynamic Link from Display Table

Bharti Ranjan
Greenhorn

Joined: Feb 11, 2009
Posts: 8
Hi Friends,

I am trying to create dynamic link from display table data, but getting error. Below is my sample code.
****************Creating Link ******************************
<display:table name="employees" id="employee" pagesize="10" export="true" requestURI="index.do">
<display:column property="username" href="Edit.do" paramId="username" paramProperty="username"/>
</display:table>



*****************Calling screen ******************************

<html:form action="/EditEmployee"
name="EmployeeForm"
type="view.EmployeeForm"
scope = "request" >
<table width="500" border="0">
<tr>
<td> <bean:message key="app.username"/> :</td>
<td>
<bean:write name="EmployeeForm" property="username" />
</td>

<td><html:text property="username" /> </td>
</tr>
<tr>
<td>
<html:submit /><html:cancel /><html:reset />
</td>
</tr>
</table>
</html:form>

When ever I am clicking link, it is opening below url:

http://localhost/App1-ViewController-context-root/Edit.do?username=Kavaya

But giving error:

java.lang.NoSuchMethodError: void org.apache.struts.taglib.html.FormTag.setName(java.lang.String) at _editemployee._jspService(_editemployee.java:60) [/editemployee.jsp]
Can any one please help me in fixing this ussue , or suggest me some sample code to create dynamic link using display table.

Thanks a lot for your kind support.

Regards
..
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1449
    
    6

Probably in your bean you are missing the setter method setName


Swastik
Bharti Ranjan
Greenhorn

Joined: Feb 11, 2009
Posts: 8
Hi Dey,

Thanks for your replly...

Buthave used getter and setter method, Below is the code for your reference

*************************************************************************
public void setUsername(String username)
{
this.username = username;
}

public String getUsername()
{

return username;
}

public void setPassword(String password)
{
this.password = password;

}

public String getPassword()
{

return password;
}

public void setName(String name)
{
this.name = name;

}

public String getName()
{

return name;
}

public void setPhone(String phone)
{
this.phone = phone;

}

public String getPhone()
{

return phone;
}

public void setEmail(String email)
{
this.email = email;

}

public String getEmail()
{

return email;
}

public void setDepid(String depid)
{
this.depid = depid;

}

public String getDepid()
{

return depid;
}

public void setRoleid(String roleid)
{
this.roleid = roleid;

}

public String getRoleid()
{

return roleid;
}

*****************************************************************

Alternatevely can you please help me in sending sample soure for creating dynamic link using display table.

Thanks a lot for your support.....
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1



Is it 'editemployee.jsp' file?, If no, then paste that. If yes, then we are missing some code here, because the error says "Can't find setter method for name property" and you didn't use 'name' property here. And please use Code Tags.


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Bharti Ranjan
Greenhorn

Joined: Feb 11, 2009
Posts: 8
Hi Sagar, Thanks for your prompt responce

Providing the complete source which I am using here, Please help.....


Calling Link in Display Tab:
==================

<display:table name="employees" id="employee" pagesize="10" export="true" requestURI="index.do">
<display:column property="name" title="Name" headerClass="sortable" />
<display:column property="phone" title="Phone" headerClass="sortable" />
<display:column property="email" title="Email" headerClass="sortable" />
<display:column property="depid" title="DepID" headerClass="sortable" />
<display:column property="roleid" title="RoleID" headerClass="sortable" />
<display:column property="username" href="Edit.do" paramId="username" paramProperty="username"/>



It is calling below jsp EditEmployee.jsp
**********************************************************************************


<html:form action="/EditEmployee"
name="EmployeeForm"
type="view.EmployeeForm"
scope = "request" >
<table width="500" border="0">
<tr>

<td> <bean:message key="app.username"/> :</td>


<td>
<bean:write name="EmployeeForm" property="username" />
</td>

<td><html:text property="username" /> </td>
<td><bean:message key="app.password"/> :</td>
<td><html:text property="password" /></td>
</tr>
<tr>

<td><bean:message key="app.phone" />:</td>
<td><html:text property ="phone" />:</td>
</tr>
<tr>
<td><bean:message key="app.email" />:</td>
<td><html:text property="email" /></td>
<td><bean:message key="app.department" />:</td>
<td>

<html:select property="depid" size="1">
<htmlption value="1">
<bean:message key="app.administration" />
</htmlption>
<htmlption value="2">
<bean:message key="app.network" />
</htmlption>

<htmlption value="3">
<bean:message key="app.engineering" />
</htmlption>

</html:select>

</td>
</tr>

<tr>
<td> <bean:message key="app.role" />:</td>
<td>'
<html:select property="roleid" size="1">
<htmlption value="1">
<bean:message key="app.manager" />
</htmlption>
<htmlption value="2">
<bean:message key="app.employee" />
</htmlption>
</html:select>
</td>
<td colspan="2" align="center">
<html:submit /><html:cancel /><html:reset />
</td>
</table>
</html:form>
</body>
</html>

Using Below EmployeeForm.java
***********************************************************************


public class EmployeeForm extends ActionForm

{

protected String username;
protected String password;
protected String name;
protected String phone;
protected String email;
protected String depid;
protected String roleid;

public void setUsername(String username)
{
this.username = username;

}

public String getUsername()
{


return username;
}

public void setPassword(String password)
{
this.password = password;

}

public String getPassword()
{

return password;
}

public void setName(String name)
{
this.name = name;


}

public String getName()
{


return name;
}

public void setPhone(String phone)
{
this.phone = phone;

}

public String getPhone()
{

return phone;
}

public void setEmail(String email)
{
this.email = email;

}

public String getEmail()
{

return email;
}

public void setDepid(String depid)
{
this.depid = depid;

}

public String getDepid()
{

return depid;
}

public void setRoleid(String roleid)
{
this.roleid = roleid;

}

public String getRoleid()
{

return roleid;
}

}


Awaiting for your kind help ..........

Regards




Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Your "html:form" tag is wrong.. Look at the correct attribute definition for html:form tag here.

Particularly, the error is in this line..



Also, you still forgot what I suggested in my previous post, Use Code Tags, It's very hard to read a code without Code Tags, and someone who wished to help you just move along to another thread.
Bharti Ranjan
Greenhorn

Joined: Feb 11, 2009
Posts: 8
Sagar,

This issue resolved after correcting syntex, Thanks for your help.....

Can you please help me by providing sample code for passing multiple argument in Creating Dynamic Link from Display Table.

Thanks......
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Bharti Ranjan wrote:Sagar,

Thanks for your help.....

My pleasure

Bharti Ranjan wrote:
Can you please help me by providing sample code for passing multiple argument in Creating Dynamic Link from Display Table.


Never used display tag, but can you elaborate what exactly you want to do ?
Bharti Ranjan
Greenhorn

Joined: Feb 11, 2009
Posts: 8
Thanks for your revert....

I want to use Display Table for my report so I need not to worry about, page formatting,pagination and export.

Here I have created dynamic link and passed 1 argumant as below:

<display:column property="username" href="Edit.do" paramId="username" paramProperty="username"/>

It is working fine, I want how to pass multiple argumant while creating dynamic link in struts Display Table .

Regards....
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Bharti Ranjan wrote:<display:column property="username" href="Edit.do" paramId="username" paramProperty="username"/>

It is working fine, I want how to pass multiple argumant while creating dynamic link in struts Display Table .


You mean you want to pass multiple parameters (not argument) to the link. I checked out display tag, there is no support to pass more than one parameter.. (As far as my short look is concerned)

Still, you can attach multiple parameter by explicitly appending it to link.. like



You can see How I modified the "href" attribute.. I'm not sure whether "bean" tag works by appending it to link, If not us EL ${userBean.id}..

Give it a try...

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem in Creating Dynamic Link from Display Table
 
Similar Threads
Verification failed on Username existence check using AJAX
Each row of a table as form
create HTML forms frm DataBase fields
Fusion Charts: How to put data into xml file ?
Struts 1 :- Two Form submission from one jsp using one submit button