Binding question

Good day all.

Let's say i have a staticText component on my page and it's binded to some database. After lounching the page staticText displays first row from database table.

is there a way to display different row. Let's say second without setting parameter in rowset query ?

thanks

[312 byte] By [dElaya] at [2007-11-26 16:28:11]
# 1

basically i'm coding dynamicaly created staticText components.

and bind these comonents to DB

dynamicTitle.setValueBinding("text", getApplication().createValueBinding("#{memberPage.articleDataProvider.value['article.title']}"));

it's not a surprise i get these staticText filled with the same content (first Row) but how do i control cursor when binding ?

please give me some hints

dElaya at 2007-7-8 22:52:29 > top of Java-index,Development Tools,Java Tools...
# 2
Hi!You can get necessary value from DB with dataprovider's function getValue(FieldKey fieldKey, RowKey rowKey).Thanks,Roman.
-Grif-a at 2007-7-8 22:52:29 > top of Java-index,Development Tools,Java Tools...
# 3

Thanks for reply Roman!

I appreciate it.

Yes that's true. I'v tried it But somehow it's not responding properly to rowset's parameter changes. You know. I'v got articleDataProvider and article rowset. And the querry in this rowset depends on the parameter article.memberID. Well and just like i said it's not responding to this parameter changes. It displays my data in staticTexts all right but there's no respond to memberID change. When i bind it it's ok but all texts contain first row. Don't know wich way to go.

Thanks

dElaya at 2007-7-8 22:52:29 > top of Java-index,Development Tools,Java Tools...
# 4
Hi!You can change RowSet's parameter.If I've understood You correctly You can do this:yourRowSet.setObject(int parameterIndex, Object x);yourDataProvider.refresh();yourDataProvider.getValue(FieldKey fieldKey, RowKey rowKey);Thanks,Roman.
-Grif-a at 2007-7-8 22:52:29 > top of Java-index,Development Tools,Java Tools...
# 5

Thanks for Your time Roman!

Yeah you understood me perfect though my english in coding matter isn't perfect.

Here's a snippet from my code

// A R T I C L E G R I D //

public HtmlPanelGrid getGridArticle() {

staticTest.setText("this is current's user ID:"+getSessionBean1().getTempUserId());// (1)

do

{

StaticText dynamicTitle=createDynamicText(articleDataProvider.getValue("article.id"));

gridArticle.getChildren().add(dynamicTitle);

}while(articleDataProvider.cursorNext());

return gridArticle;

}

private StaticText createDynamicText(Object i){

//i-articleID from DB

StaticText dynamicTitle=new StaticText();

try{

article.setObject(1,getSessionBean1().getTempUserId());

articleDataProvider.refresh();

Object title=articleDataProvider.getValue("article.title");

dynamicTitle.setText(title);

dynamicTitle.setId("_"+i);

//dynamicTitle.setValueBinding("text", getApplication().createValueBinding("#{memberPage.articleDataProvider.value['article.title']}"));

}catch(Exception e){}

return dynamicTitle;

}

It displays my titles ok (for the first time) but when i change Object x in rowset my dataProvider doesn't seem to response to this changes.

I dragged to the page two additional staticText components to check out what's going on...

--1--

staticTest.setText("this is current's user ID:"+getSessionBean1().getTempUserId())//(1);

--2--

and second one which has been bound

#{SessionBean1.tempUserId}

i change tempUserId in another tab of the same page (imageHyperlink with actionListener attached and what i get is

(1)isn't changing

(2)changes all right

any ideas what might be wrong ?

again thanks for your time Roman

i appreciate it!

dElaya at 2007-7-8 22:52:29 > top of Java-index,Development Tools,Java Tools...
# 6
Hi!Are You sure that when You try to change Object x in rowset it is new (not old value)? Try to check it.Thanks,Roman.
-Grif-a at 2007-7-8 22:52:29 > top of Java-index,Development Tools,Java Tools...
# 7

Thanks Roman !

Yes i'm sure. It is a new value. But check out what i found out after some research and various testing of my app.

getGridArticle() method contains

staticTest.setText("this is current's user ID:"+getSessionBean1().getTempUserId())//(1);

so i can check what's going on with the Object x value.

no response on this

but when i trigger exactly the same action with the button

public String testButton_action() {

staticTest.setText("this is current's user ID:"+getSessionBean1().getTempUserId());

return null;

}

this value is being nicely refreshed on the page!

conclusion?

getGridArticle is called only once at the beginning. When and where is it actually called? Switching between tabs on my page doesn't make any difference (and i'd want it to).

But hey!

staticTest is in gridArticle too so hitting the button should refresh whole gridArticle content.

I'm wondering about the fact that the other staticText components were generated dynamicaly. Hmmm. Headache :)

Correct me if i'm wrong somwhere along my blah blah blah and most of all thanks for your time and your patience.

Thanks,

dElay

dElaya at 2007-7-8 22:52:29 > top of Java-index,Development Tools,Java Tools...
# 8

Hi!

Where You call getGridArticle()?

Also draw attention that when You click button, the page, where this button is placed, is initialized, then button event handler is called, and then the page is initialized with results of button event handler (if only I didn't make a mess).

Thanks,

Roman.

-Grif-a at 2007-7-8 22:52:29 > top of Java-index,Development Tools,Java Tools...
# 9
To be honest i don't know. It's defined in the main class of the page public class memberPage extends AbstractPageBean {Thanks,dElay
dElaya at 2007-7-8 22:52:29 > top of Java-index,Development Tools,Java Tools...
# 10
Hi!getGridArticle() is called when You load the page.When You click button, You submit page and server process request. When You click Tab I'm not sure that page is subminted to the server.Try to debug and understand where problem is.Thanks,Roman.
-Grif-a at 2007-7-8 22:52:29 > top of Java-index,Development Tools,Java Tools...
# 11
Thanks for all help so far Roman.You'r right. It's the highest time to make use of debbuger. I hope my next post will end with solved word :)thanks,dElay
dElaya at 2007-7-8 22:52:29 > top of Java-index,Development Tools,Java Tools...