cancel
Showing results for 
Search instead for 
Did you mean: 

How to align a dynamic UI to the right?

Former Member
0 Kudos

Hello,

I've created a UI dynamically using this code:

IWDTextView t = (IWDTextView) view.createElement(IWDTextView.class, null);

and I would like to set it's alignment at the screen at the right corner (the default is left). I beleive I need to use the method bindHAlign but I don't know how to use it. Can anyone please show me code example?

Roy

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Roy,

Try to do this statically first, i.e. inside view's layout designer.

If it is impossible using designer, then it is a WebDynpro bug, if designer view and run-time view are different, then it's either a WebDynpro bug or locale issue.

Valery Silaev

EPAM Systems

http://www.NetWeaverTeam.com

Former Member
0 Kudos

(Psst, I tell you a secret: There will be (almost) no difference in rendering anymore between runtime and designtime in future NWDS releases)

Armin

Former Member
0 Kudos

Put the TextView inside a MatrixLayout, set TextView.layoutData=MatrixHeadData with hAlign=WDCellAlign.FORCED_RIGHT.

Armin

Former Member
0 Kudos

>Put the TextView inside a MatrixLayout, set >TextView.layoutData=MatrixHeadData with >hAlign=WDCellAlign.FORCED_RIGHT.

Armin, could u please show me a detailed code example of how to acheive this?

Thank you in advance,

Roy

Former Member
0 Kudos
IWDTransparentContainer c = (IWDTransparentContainer) view.createElement(IWDTransparentContainer.class, null);
c.createLayout(IWDMatrixLayout.class);
IWDTextView text = (IWDTextView) view.getElement("<ID>");
IWDMatrixHeadData layoutData = (IWDMatrixHeadData) text.createLayoutData(IWDMatrixHeadData.class);
layoutData.setHAlign(WDCellAlign.FORCED_RIGHT);
c.addChild(text);

Armin

Former Member
0 Kudos

Hi,

Assuming it is not resolved due to some unknown error..

U can still create a transparent container statically..

set its height and widtha and align it wherever necessary,..

and while u r creating ur UI elements which u want to align to right.. add them to this container.

so.. u will acheive that effect..

This will save a lot of dynamic UI code..

I prefer this is most of the scenarios.. and u can always say it will work in the manner u want to..:)

Rgeards

Bharathwaj

Former Member
0 Kudos

Hey Bharathwaj,

I thought of it and implemented it but no matter which method I choose, I still see the lables and text fields at the left. By the way, I am using Grid Layout with 2 cols. I tried Matrix but still got the same result...

Roy

Former Member
0 Kudos

Hi,

Thats strange..

Let me assume i start with a clean view.

I have the RootContainerUI element, i will set its width to 800.StretchHorizontally to false.(No reson for this).

Now i will create a gridlayout or a matrix layout..

Grid - with 2 columns.. First a invisible element of say width 600. Then a transparent container,of width 200.

Now i will add the dynamically created elements in this container..

Works fine ?

Regards

Bharathwaj

Former Member
0 Kudos

the elements are added but to the left....

Former Member
0 Kudos

What about the language settings in IE?

Perhaps they are overriding your left/right allingment code. You say right, IE is set rtl so it pushes left instead.

Former Member
0 Kudos

Means ? you are saying.. the container is in teh position u need..

Elements are added inside the container.. but inside the container they are added to the left.. Can u send me the screen shot of the layout (Outline) and the view..

I want to see.. is the container in left or right ?

Former Member
0 Kudos

Hey Bharathwaj,

The container halign is set to right.

I sent you scrteenshots to the .com email address.

I am refering to the "Part2" Container.

Former Member
0 Kudos

Very sorry. One small problem with the screen shot.. Its the part2scroll container..i get it.. but i cant fine it in the view.. is it the one set with the value "b".. and in you right to left applciations.. isnt the placing of UI elements the reverse direction.. ?

And can u add a inivisible element.. whch u have not added till now and set its width.. !

Message was edited by: Bharathwaj R

Former Member
0 Kudos

Hi Roy,

I haven't tried this, I've just had a look at the API but have you tried setHAlign(WDInputFieldAlignment.FORCED_RIGHT)?

Patrick.

Former Member
0 Kudos

Hey Patrick,

I've already tried that, Unfortunally it's not working...

Former Member
0 Kudos

Strange one. I don't think though that bindHAlign is going to help since it just binds the hAligh property to a context attribute that you'd then have to set to one of the WDInputFieldAlignment values, such as FORCED_RIGHT; which we already know doesn't work.

Have you tried WDInputFieldAlignment.BEGIN_OF_LINE, that should push the UIElement to the right if you're settings are Right to Left, which I suspect they may be.

Strange one indeed.

Patrick.

EDIT: You may as well try all of the WDInputFieldAlignment.FIELD values just to rule out any left to right / right to left issues. WDInputFieldAlignment.CENTER should be a good one to rule out those issues.

Message was edited by: Patrick O'Neill

Former Member
0 Kudos

But why using an WDInputFieldAlignment when I build lables and text fields?

Former Member
0 Kudos

Hi Roy,

>But why using an WDInputFieldAlignment when I build lables and text fields?

For IWDTextView, like you originaly asked about, the hAlign property wants a WDInputFieldAlignment.FIELD value.

IWDLabel objects don't have an hAligh property, but a TextDirection, which wants a WDTextDirection.FIELD value.

It could be related to the container type that you have your UI elements inside.

Patrick.