If you are using Internet Explorer, please remove blackberry.com from your compatibility view settings.

Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
myquestion
Posts: 235
Registered: ‎11-12-2008
My Device: Not Specified
Accepted Solution

How to implement dynamic RadioButton ?

HI,

Any one how to implement dynamic radio button...

I want 3 radio button...which will be dyanmically update from server...

 

using VerticalManager..

 

Thanks in advance..

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to implement dynamic RadioButton ?

What do you mean by dynamic?  Can you explain what will change with different content from the Server?

 

I would suggest at this stage you treat this as two different problems:

1) Getting content from a Server

2) Updating the User Interface with content

Splitting will make development simpler and will enable you to test your code more effectively too. 

 

So for now concentrate on the UI update.  Create a 'pretend' connection to the Server, and have it return fixed data that you can easily set and change, and then concentrate on getting the radio buttons to work how you want. 

Please use plain text.
Developer
myquestion
Posts: 235
Registered: ‎11-12-2008
My Device: Not Specified

Re: How to implement dynamic RadioButton ?

public void updatePolicy()
{
synchronized (UiApplication.getUiApplication().getEventLock()) {

radioButtonGroup = new RadioButtonGroup();
for (int i = 0; i < allItPolicyResponseData.getPolicyName().length; i++) {
buttonField1 = new RadioButtonField(allItPolicyResponseData.getPolicyName()[i].toString());
radioButtonGroup.add(buttonField1);
// this.add(buttonField);
}
}
}

Not updating...

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to implement dynamic RadioButton ?

Why is the following code commented out?

// this.add(buttonField);

 

 

Please use plain text.
Developer
myquestion
Posts: 235
Registered: ‎11-12-2008
My Device: Not Specified

Re: How to implement dynamic RadioButton ?

RadioButtonField buttonField1 ;
VerticalFieldManager vfm00;
private void buildITPOLICY()
{
try{
vfm00 = new VerticalFieldManager();
radioButtonGroup = new RadioButtonGroup();

buttonField1 =new RadioButtonField()
{
protected void paint(Graphics graphics)
{
graphics.setColor(Color.BLACK);

super.paint(graphics);
}
};



vfm00.add(buttonField1);

mainManager.add(vfm00);
}catch(Exception e){System.out.println("=======Exceptio=addMiddleSecondPanel==="+e);}


}

 

public void updatePolicy()
{
synchronized (UiApplication.getUiApplication().getEventLock()) {

for (int i = 0; i < allItPolicyResponseData.getPolicyName().length; i++) {
buttonField1 = new RadioButtonField(allItPolicyResponseData.getPolicyName()[i].toString());
radioButtonGroup.add(buttonField1);
vfm00.add(buttonField1);
}
}
}

 

from my controller screen i called   updatePolicy() method it automaticall update the buildITPOLICY() methond with its manager vfm00..

 

IT is giving illegalStateException...

 

Please use plain text.
Developer
myquestion
Posts: 235
Registered: ‎11-12-2008
My Device: Not Specified

Re: How to implement dynamic RadioButton ?

ok ,thanks i have solved the problem..

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to implement dynamic RadioButton ?

Great, Can you mark the problem as solved and confirm what you did that fixed it?  Thanks

Please use plain text.
Developer
myquestion
Posts: 235
Registered: ‎11-12-2008
My Device: Not Specified

Re: How to implement dynamic RadioButton ?

solution:

synchronized (UiApplication.getUiApplication().getEventLock())
{
for (int i = 0; i < allItPolicyResponseData.getPolicyName().length; i++) {
buttonField1 = new RadioButtonField(allItPolicyResponseData.getPolicyName()[i].toString(),radioButtonGroup,false)
{
protected void paint(Graphics graphics)
{
graphics.setColor(Color.BLACK);

super.paint(graphics);
}
};
System.out.println("--------------------i----"+i);
vfm00.add(buttonField1);
}
}

Please use plain text.