Re: Several entities and DataTable

2010-01-10 Thread James Carman
Yes, so if you had a list of Milk objects, you could use a property
expression "honey.honeyName."  Nested property expressions work.

On Sun, Jan 10, 2010 at 10:31 AM, Ivan Dudko  wrote:
> James, You mean this?
>
> class Milk {
> int id;
> String milkName;
> Honey honey;
> // getters and setters
> }
>
> class Honey {
> int id;
> String honeyName;
> // getters and setters
> }
>
> 2010/1/10 James Carman :
>> Can you "traverse" from Milk to Honey (or vise-versa)?  If so, then
>> just use a nested property expression (like "honey.hiveName" or
>> whatever).
>>
>> On Sun, Jan 10, 2010 at 9:51 AM, Ivan Dudko  wrote:
>>> I have two Pojo classes. For example, Milk and Honey.
>>> And also database tables with same structure. I am do not use ORM mapping.
>>>
>>> I write DAO class for class Milk that fetches data from the tables
>>> milk and honey at once.
>>> But i am in trouble how i can display this result set.
>>>
>>> I think that writing third Pojo MilkHoney for displaying this data is
>>> bad idea...
>>>
>>> Thank you!
>>>
>>> -
>>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>>> For additional commands, e-mail: users-h...@wicket.apache.org
>>>
>>>
>>
>> -
>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>> For additional commands, e-mail: users-h...@wicket.apache.org
>>
>>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Several entities and DataTable

2010-01-10 Thread Ivan Dudko
James, You mean this?

class Milk {
int id;
String milkName;
Honey honey;
// getters and setters
}

class Honey {
int id;
String honeyName;
// getters and setters
}

2010/1/10 James Carman :
> Can you "traverse" from Milk to Honey (or vise-versa)?  If so, then
> just use a nested property expression (like "honey.hiveName" or
> whatever).
>
> On Sun, Jan 10, 2010 at 9:51 AM, Ivan Dudko  wrote:
>> I have two Pojo classes. For example, Milk and Honey.
>> And also database tables with same structure. I am do not use ORM mapping.
>>
>> I write DAO class for class Milk that fetches data from the tables
>> milk and honey at once.
>> But i am in trouble how i can display this result set.
>>
>> I think that writing third Pojo MilkHoney for displaying this data is
>> bad idea...
>>
>> Thank you!
>>
>> -
>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>> For additional commands, e-mail: users-h...@wicket.apache.org
>>
>>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Several entities and DataTable

2010-01-10 Thread James Carman
Can you "traverse" from Milk to Honey (or vise-versa)?  If so, then
just use a nested property expression (like "honey.hiveName" or
whatever).

On Sun, Jan 10, 2010 at 9:51 AM, Ivan Dudko  wrote:
> I have two Pojo classes. For example, Milk and Honey.
> And also database tables with same structure. I am do not use ORM mapping.
>
> I write DAO class for class Milk that fetches data from the tables
> milk and honey at once.
> But i am in trouble how i can display this result set.
>
> I think that writing third Pojo MilkHoney for displaying this data is
> bad idea...
>
> Thank you!
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Several entities and DataTable

2010-01-10 Thread Ivan Dudko
I have two Pojo classes. For example, Milk and Honey.
And also database tables with same structure. I am do not use ORM mapping.

I write DAO class for class Milk that fetches data from the tables
milk and honey at once.
But i am in trouble how i can display this result set.

I think that writing third Pojo MilkHoney for displaying this data is
bad idea...

Thank you!

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Several entities and DataTable

2010-01-10 Thread Ivan Dudko
2010/1/10 Leo Erlandsson :
>
> I would use an SQL Join in the iterator(int first, int count) method to get
> data from the associated table and return the data in the returned Domain
> Objects.
>
> You could also do an SQL Query for each result in your iterator() method,
> but that would give you 1+n SQL Queries instead of just 1.
>
> Also, note that your code has several Security Vulnerabilities as it is
> susceptible to SQL Injection Attacks (!) if you let the user specify the
> Filter String:
>
> String tmp = filter.getName();
> sql = "where name like '%" + tmp + "%'";
>
>
>
>
>
> -
> ---
> Leo Erlandsson, M. Sc.
> --
> View this message in context: 
> http://old.nabble.com/Several-entities-and-DataTable-tp27075166p27097481.html
> Sent from the Wicket - User mailing list archive at Nabble.com.

Can you give me an example?

this is only for test:
 String tmp = filter.getName();
 sql = "where name like '%" + tmp + "%'";

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Several entities and DataTable

2010-01-10 Thread Leo Erlandsson

I would use an SQL Join in the iterator(int first, int count) method to get
data from the associated table and return the data in the returned Domain
Objects.

You could also do an SQL Query for each result in your iterator() method,
but that would give you 1+n SQL Queries instead of just 1.

Also, note that your code has several Security Vulnerabilities as it is
susceptible to SQL Injection Attacks (!) if you let the user specify the
Filter String:

String tmp = filter.getName();
sql = "where name like '%" + tmp + "%'"; 





-
---
Leo Erlandsson, M. Sc.
-- 
View this message in context: 
http://old.nabble.com/Several-entities-and-DataTable-tp27075166p27097481.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Several entities and DataTable

2010-01-09 Thread Ivan Dudko
This is DataProvider and ListPage.
All is fine where i work with only one entity.
My DAO returns data from table assotiated with this entity and another table.
How i can provide access to this data from my DataTable?


public class MyDomainDataProvider extends
SortableDataProvider implements IFilterStateLocator {

DataSource dataSource = QueryFactory.getDataSource();
private final MyDomainDAOImpl dao = new MyDomainDAOImpl(dataSource);
private MyDomain filter = new MyDomain();
private String sql = new String();

public MyDomainDataProvider() throws QueryException {
// set default sort
setSort("id", true);
filter.setId(null);
}

public Iterator iterator(int first, int count) {
SortParam sp = getSort();
//String x = FilterCriterionFactory.getFilteredSQL(filter);
String tmp = filter.getName();
if (tmp != null) {
sql = "where name like '%" + tmp + "%'";
} else {
sql = "where name like '%'";
}
Integer tmp2 = filter.getId();
if (tmp2 != null) {
sql += " and id like '%" + tmp2 + "%'";
}

return (Iterator)
dao.getDataAsEntity(MyDomain.class, first, count, sp.getProperty(),
sp.isAscending(), "select * from mydomain " + sql).iterator();
}

public IModel model(MyDomain my) {
return new Model(my);
}

public int size() {
String tmp = filter.getName();
if (tmp != null) {
//sql = "where name like '%" + tmp + "%'";
} else {
//sql = "where name like '%'";
}
Integer tmp2 = filter.getId();
if (tmp2 != null) {
sql += " and id like '%" + tmp2 + "%'";
}
return dao.getResultSetFullSize(MyDomainDAOImpl.SELECT_ALL_SQL + sql);
}

public Object getFilterState() {
return filter;
}

public void setFilterState(Object state) {
filter = (MyDomain) state;
}
}


public MyListPage(PageParameters params) throws QueryException {
MyDataProvider provider = new MyDataProvider();

IColumn[] columns = new IColumn[]{
new PropertyColumn(new
Model(getString("List.FieldName.Id")), "id", "id"),
new TextFilteredPropertyColumn(new
Model(getString("List.FieldName.Name")), "name", "name"),
new TextFilteredPropertyColumn(new
Model(getString("List.FieldName.Ip")), "ip", "ip"),
new TextFilteredPropertyColumn(new
Model(getString("List.FieldName.Port")), "port", "port"),
new TextFilteredPropertyColumn(new
Model(getString("List.FieldName.Description")), "description",
"description"),
new PropertyColumn(new
Model(getString("List.FieldName.NodeId")), "nodeid"),

new FilteredAbstractColumn(new
Model(getString("List.Actions"))) {

public Component getFilter(String componentId,
FilterForm form) {
return new GoAndClearFilter(componentId, form, new
ResourceModel("List.Filter"), new ResourceModel("List.Clear"));
}

public void populateItem(Item cellItem, String
componentId, IModel rowModel) {
cellItem.add(new UserActionsPanel(componentId, rowModel));
}
}
};

AjaxDataTable dataTable = new AjaxDataTable("table", columns,
provider, 2);
final FilterForm form = new FilterForm("filter-form", provider);
dataTable.addTopToolbar(new FilterToolbar(dataTable, form, provider));
form.add(dataTable);
add(form);
}

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Several entities and DataTable

2010-01-08 Thread Martin Makundi
Show your code.

2010/1/8 Ivan Dudko :
> Hello!
>
> I am not using JPA and Spring. Write all with plain JDBC.
> I am write page which displays data with DataTable using SortableDataProvider.
> How i can display fields from another table (entity)?
>
> Wicket says that no get method found.
>
> Thank you!
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Several entities and DataTable

2010-01-08 Thread Ivan Dudko
Hello!

I am not using JPA and Spring. Write all with plain JDBC.
I am write page which displays data with DataTable using SortableDataProvider.
How i can display fields from another table (entity)?

Wicket says that no get method found.

Thank you!

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org