aspose file tools*
The moose likes JSF and the fly likes h:panelGrid  with Attribute value 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 » Java » JSF
Bookmark "h:panelGrid  with Attribute value" Watch "h:panelGrid  with Attribute value" New topic
Author

h:panelGrid with Attribute value

Nishita Jain
Ranch Hand

Joined: Mar 30, 2006
Posts: 97
hi,
i tried much to find exapmle on <h:panelGrid value="#{backingBean.all}">
but couldnt find that.
Can you give me 1 example how to do that.

Thnaks,
Nishita


Nishita
deepak reads
Greenhorn

Joined: Nov 01, 2004
Posts: 13
This is taken from Kitto D. Mann which i bought yesterday

This will appear in two rows..
Nishita Jain
Ranch Hand

Joined: Mar 30, 2006
Posts: 97
hi,
Thnaks for reply.
but this is not what i want.
i actually want example on how u can relate panelgrid with attribute Value.
like,
<h:panelGrid value="#{backingBean.all}">

Thank you.
Rajeev Ravindran
Ranch Hand

Joined: Aug 27, 2002
Posts: 455
What do you mean by relating panelGrid with attribute values ? Can you elaborate on that ?

Thanks,
madhuri madhuri
Ranch Hand

Joined: Jan 18, 2006
Posts: 58
Originally posted by Nishita Jain:
hi,
Thnaks for reply.
but this is not what i want.
i actually want example on how u can relate panelgrid with attribute Value.
like,
<h: panelGrid value="#{backingBean.all}">

Thank you.


If I understood what you mean to say correctly,
<h: panelGrid> doesnot have an attribute called "value". It has a "binding" attribute. You may want to check that if you want to bind it to a value in your backing bean. <h: panelGrid>


~Madhuri
Nishita Jain
Ranch Hand

Joined: Mar 30, 2006
Posts: 97
hi,
i refered this site.
http://www.horstmann.com/corejsf/jsf-tags.html#Table4_24

and if that tag is not available then how to achieve that functionality which we can do aby Value attribute

Thank you,
Nishita
Rajeev Ravindran
Ranch Hand

Joined: Aug 27, 2002
Posts: 455
Hi Nishita, If you explain your requirement, somebody can help you with example code or provide you an alternate solution. I would say dont waste time for something which is not provided by the framework.
I remember once wanted to remove <table> from the JSF generated html file but what you required was to keep text fields beside radio buttons. It was not required to remove <table> from html for that scenario. Can you explain what you want to acheive with panelGrid? Are are trying to add components to the grid or trying to create a new grid dynamically ?

Thanks,
Rajeev.
[ April 10, 2006: Message edited by: Rajeev Ravindran ]
Nishita Jain
Ranch Hand

Joined: Mar 30, 2006
Posts: 97
hello Rajeev,
yes i think you are right.
ok what i actually want to do is
that i want achieve the same functionality which we can ,by using h:datatable

i mean i want to make loop of listing of some Tests from database so its dynamic. and in every row there is a checkbox to select the Test and you can select multiple test.now the problem is that if i use h:datatable for every checkbox table is generated and for that problem i found the solution in this forum only . you can refer it if you want . its Subject name is in h:selectOneRadio automatically creates Table posted by me. from that i got solution of using h:panelgrid. but i come up with one problem that how to loop using h:panelgrid. i even try using SelectBooleanChkbox . in that case table is not generated with every checkbox . but i couldnt find out which test is selected. For every test there is testid related to that.That is it.
any other solution from your side is valuable.
Thnak you.
Nishita
Rajeev Ravindran
Ranch Hand

Joined: Aug 27, 2002
Posts: 455
If you are trying to generate the ouput in the same page, you can go to the root component and write code in your backing bean to generating panelgrid and adding components to the grid. I have done something similar to this and its pretty simple. Instaed of value binding from panelGrid, did you try creating the panelGrid from the backing bean and adding the new panelgrid to the root componenet (this root component could be a form for you, in my case it is an HtmlTabItem)

a few lines of code

HtmlPanelGroup panelGroup1_1 = new HtmlPanelGroup();

HtmlPanelGrid panelGrid1_1 = new HtmlPanelGrid();
panelGrid1_1.setColumns(8);
panelGrid1_1.setCellspacing("5");

panelGrid1_1.getChildren().add(createOutputText("First Name:","styleMandatory"));
panelGrid1_1.getChildren().add(createInputText("txtFirstName"));
panelGroup1_1.getChildren().add(panelGrid1_1);
parentPanelGroup.getChildren().add(panelGroup1_1);

scriptCollector.getChildren().add(parentPanelGroup);
namingContainer.getChildren().add(scriptCollector);
tabItem.getChildren().add(namingContainer);

Thanks,
Nishita Jain
Ranch Hand

Joined: Mar 30, 2006
Posts: 97
hello,can u please give me a example on this. i tried finding but not got for the Htmlpanelgrid
what i got i can be like this
public class BackingBean {

private UIComponent panelGroup() ;

public UIComponent getPanelGroup(){

HtmlPanelGroup panelGroup1 = new HtmlPanelGroup();

HtmlPanelGrid panelGrid1_1 = new HtmlPanelGrid();
panelGrid1_1.setColumns(1);

panelGrid1_1.getChildren().add(createOutputText("Test Name:"));

panelGroup1_1.getChildren().add(panelGrid1_1);
parentPanelGroup.getChildren().add(panelGroup1_1);


return panelGroup;
}
public void setPanelGroup(UIComponent panelGroup)
{
this.panelGroup = panelGroup;
}
}

now here i have only 1 colum
i mean i want to display like

TestName Checkbox

1(name) []
2(name) []

now here 1 2 coming from database so must fire a query and i must relate this name with panel grid
how can i do that? and can u give me any example or link for that.

Thank you.
Rajeev Ravindran
Ranch Hand

Joined: Aug 27, 2002
Posts: 455
Originally posted by Nishita Jain:


HtmlPanelGrid panelGrid1_1 = new HtmlPanelGrid();
panelGrid1_1.setColumns(1);

panelGrid1_1.getChildren().add(createOutputText("Test Name:"));

panelGroup1_1.getChildren().add(panelGrid1_1);
parentPanelGroup.getChildren().add(panelGroup1_1);

change setColumns to 2.
panelGrid1_1.setColumns(2);

now the grid has 2 columns, so when you add four components, each row will contain 2 components. hope it expalins..

Since you are retreiving data from database, store it in a list , iterate through the list , create new components and add it to your panelgrid ? cant you do it yourself

Thanks,
Nishita Jain
Ranch Hand

Joined: Mar 30, 2006
Posts: 97
Hi Rajeev ,
as per you said i did that using PanelGrid with List . but then again 1 problem is there,
i m fetching test names fro database . i created panelGird for that and for each test i also put 1 checkbox and i created column for that. but i dont know how to get the values for the selected chkbox. i dont know how to givw different name related to each chkbox.
i dont give any name it generates like
<input name="addUserForm:_id9" value="194" type="checkbox"> </input>
<input name="addUserForm:_id10" value="194" type="checkbox"> </input>
.
.
.
is there any way so that i can give name like
<input name="addUser[0]" value="194" type="checkbox"> </input>
<input name="addUser[1]" value="194" type="checkbox"> </input>
...
my coding for that column is like this and it displays perfectly.
while (rs.next()) {
for (int i = 1; i <= rslist.size(); i++) {
HtmlOutputText text = new HtmlOutputText();
text.setValue(rs.getString(i));
panelChildren.add(text);
if(i == 1)
testId = (String)text.getValue();;
if(i%4 == 0){
List valueList = new ArrayList();

HtmlSelectManyCheckbox chkbox = new HtmlSelectManyCheckbox();
UISelectItems items = new UISelectItems();
SelectItem selectCheckItems = new SelectItem(testId,"");
valueList.add(selectCheckItems);
items.setValue(valueList);
chkbox.getChildren().add(items);
panelChildren.add(chkbox);
}

}

}

i tried searching in this forum and found one but there was no Answer.

Thanks,
Nishita
Rajeev Ravindran
Ranch Hand

Joined: Aug 27, 2002
Posts: 455
Originally posted by Nishita Jain:


HtmlSelectManyCheckbox chkbox = new HtmlSelectManyCheckbox();UISelectItems items = new UISelectItems(); SelectItem selectCheckItems = new SelectItem(testId,"");


you can provide an unique id for ur checkboxes

chkbox.setId("checkbox" + i);
value of i increments in your for loop.. try it out

Thanks,
qq qq
Greenhorn

Joined: Jul 19, 2006
Posts: 1
here is my suggestion. russian resource.

i've patched myfaces's newspaperpanel.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

"qq qq",
Welcome to the JavaRanch.

We're a friendly group, but we do require members to have valid display names.

Display names must be two words: your first name, a space, then your last name. Fictitious names are not allowed.

Please edit your profile and correct your display name since accounts with display names get deleted, often without warning

thanks,
Dave
Brunda Gundamaraj
Greenhorn

Joined: Aug 13, 2008
Posts: 11
["Brunda G", please post your questions in a new topic rather than hi-jacking someone else's. Also check your private messages for an important administrative matter.]
[ August 13, 2008: Message edited by: Bear Bibeault ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: h:panelGrid with Attribute value