GWT: Widget/Template and ClientBundle - templates

which combinations of Widget/Template and ClientBundleare allowed, and are there any known limitation / things you should consider when using them.
Afaik something like:
#Template(""{0}\"<p>not allowed</p>")
SafeHtml iconONLY(Widget w);
isn't allowed since it throws an error.
Something like
#Template("{0}<p>not allowed</p>")
SafeHtml iconONLY(Element e);
and use it with something like iconONLY(w.getElement()); is possible, but the Widget loses all functionality, because it's attache method isn't executed correctly.
To summ it up, I assume that Templates are not intended to have Widgets placed inside them!
ClientBundle are intended hold the content Widgets. Using them inside other elements e.g: like
#Template("{0}<p>not allowed</p>")
SafeHtml iconONLY(SafeUrl safeurl);
called with iconONLYimageResource.getSafeUrl); can cause problems...
Are my assumptions correct? Please tell me if you tryed/ used one of the combination and how it worked?

The first and the second ones makes sense that they don't work, since you are trying to insert just the element or widget into a string (SafeHtml is at the end of the day just a String) - of course the event wiring won't work. Widgets cant be cloned like that, there is more to them then just the element they are made of.
The last is an error because you are putting a Uri into the text content - you probably mean something like
#Template("<img src=\"{0}\" /><p>not allowed</p>")
SafeHtml iconONLY(SafeUri safeurl);
to display an image.
What are you trying to do? If trying to display an image, putting the SafeUri in an img tag is one option, another would be to put together a SafeHtml instance to insert:
#Template("{0}<p>not allowed<p>")
SafeHtml iconONLY(SafeHtml icon);
//...
AbstractImagePrototype proto = AbstractImagePrototype.create(icon);
SafeHtml iconHtml = SafeHtmlUtils.fromTrustedString(proto.getHTML());
template.iconONLY(iconHtml);
The basic idea of SafeHtml is that you build up strings of html instead of dom elements - this allows those strings to be reused, or to all be injected at once (which is usually faster than appending elements to the dom) - this is not how widgets are added to one another, and trying to manipulate widgets like this will just end up with missing pieces, as you've noticed.

Related

Is there a way to get scrollstate from Lazyrow

I have made a LazyRow that i now want to be able to get the scrollposition from. What i understand Scrollablerow has been deprecated. (correct me if im wrong) The thing is that i cant make a scrollablerow so i thought lets make a lazy one then. but i have no clue how to get scrollposition from the lazyrow. i know how to get index but not position if that eaven exists. here is what i have tried.
val scrollState = rememberScrollState()
LazyRow(scrollState = scrollstate){
}
For LazyScrollers, there are separate LazyStates.
I think there's just one, in fact, i.e. rememberLazyListState()
Pass that as the scroll state to the row and then you can access all kinds of info. For example, you could get the index of the first visible item, as well as its offset. There are direct properties for this stuff in the object returned by the above initialisation. You can also perform some more complex operations using the lazyListState.layoutInfo property that you get.
Also, ScrollableRow may be deprecated as a #Composable, but it is just refactored, a bit. Now, you can use the horozontalScroll() and verticalScroll() Modifiers, both of which accept a scrollState parameter, which expects the same object as the one you've created in the question.
Usually, you'd use LazyScrollers since they're not tough to implement and also are super-performant, but the general idea is that they are used with large datasets whereas non-lazy scrollers are okay for small sized lists and stuff. This is because the lazy ones cache only a small fraction of the entire list, making your UI peformant, which is not something regular scrollers do, and not a problem for small datasets.
They're like equivalents of RecyclerView from the View System

Nested tables in livecycle fall apart on email

I have a form here with a nested table - where each table can dynamically grow, i.e., the inner table (w/ Transit No and Account No) and the outer table (Accounts by ID No). Here is an example:
(Behind the buttons:
Add - $.parent.tbl.Row.instanceManager.addInstance();
Remove - $.parent.instanceManager.removeInstance(this.parent.index); (In
production I make sure there is at least one row to remove...)
In the definition for each table I do not have checked 'Repeat Table for Each Data Item'. This works great. However I did try with that checked and the outcome was the same.
Now, when I email the form and open the attachment, this is what I see:
You can see that the second table didn't make it, and apparently a row was added to the inner table in the first, without any data.
Any ideas on what's going wrong here? And what I can do about it?
Unfortunately I'm not sure what's wrong with your form but I have made a similar form that works - so I can show you how I did it and list a few things that I can think of that can cause problems.
This is what my form looks like and when I e-mail it, it comes out exactly the way it is:
(It has repeatable parent- and childsubforms like yours)
I did it entirely with JS though, no FormCalc and Dollar $igns :D
When a button is pressed I call a function from a Scriptobject.
These are the main parts of my script inside my functions:
Adding a Subform:
var oNewInstance = subform.instanceManager.addInstance(1);
Deleting a Subform:
if (subform.instanceManager.count > subform.instanceManager.occur.min)
{
subform.instanceManager.removeInstance(subform.index);
}
And these are my subforms' properties (in German, but you can figure it out :P):
Your problem might also have completely other reasons though, make sure you don't have any changes in an initialize,docReady, preSubmit and similar actions that occur between sending and opening the sent PDF.
Also before sending it as an e-mail you have to save it in Acrobat as a Reader Extended PDF:
Besides that I've noticed that sometimes problems can occur due to the target version (Selectable in LCD under File > Form Properties > Defaults).
It helped me sometimes to set it to the newest one.

Kivy: set ListProperty from kv language

I am using Kivy to build a simple app that would load different images in different tabs of a tabbed panel. The different Panel items should all behave similarly, but with different images, so I created a widget class. I am trying to initialize my app using the kv language like in many examples.
Currently, I am unable to make it work, because I cannot find how to pass the file names in a list from the kv language part to the widget instance. I am able to work with other Properties, but the ListProperty has me stumped.
Here is a snippet from my code:
Builder.load_string("""
<MyMainClass>:
#stuff
TabbedPanelItem:
MyClassLayout:
filenames: ['pic1.jpg', 'pic2.jpg', 'pic3.jpg', 'pic4.jpg']
#other TabbedPanelItems like the one above,
#with different strings in the list
""")
def MyMainClass(TabbedPanel):
pass
def MyClassLayout(FloatLayout):
filenames = ListProperty([])
#rest of my class
Things I already tried:
Use different parentheses in assigning the list in the kv language part: I tried () and {}, as well as with no parentheses.
Initialize the ListProperty differently: I tried putting some string in it already.
Send different lists: I tried sending numbers instead of strings.
The result is always that the filenames list in my widget is always at the default value. That would be [] in the snippet above, or whatever I set in its declaration in my class.
Would someone please point out what it is I am doing wrong?
Thanks.
I managed to fix this.
The issue was that I was trying to read the lists in the constructor. However, they receive their value from the kv lang part after the widget object has finished its constructor.
As a fix, I call the method that reads the list like so:
Clock.schedule_once(self.late_init, 0.02)
I hope people find this and it helps them.

Putting Controls at ToolBar- Stuck

I have been staring at this documentation for 5 hours now. I simply cant connect the steps. If you guys can enlighten me of the stuff.
Here is the site:
http://msdn.microsoft.com/EN-US/library/bb983718(VS.110).aspx
So my problem are the following:
-at number 5, it asked me to "Set these parameters as follows:", it didnt even mention anything about where? Where to implement the constructor, and why are we using CMFCToolbarComboBoxButton? when it already asked me at step 4 to derive a clas called CFindComboButton. Shouldnt I be making a contstructor for that one instead?
-at number 4(sorry about the non organized numbering of problems), what I did is use the add class (not the class wizard), and then I picked MFC Class. I then enter the supposedly CFindComboButton and Base class as CMFCToolBarComboBoxButton. Did I do something wrong on this one? Do I have to do anything for the ID ID_EDIT_FIND_COMBO?
-When I register the ID_EDIT_FIND_COMBO at the String Table, I dont exactly know what I did. Did I just register an id for future implementation? or is it something else?
-So I cant do step 5, I skipped to step 6. All it ask me is to look for the CreateCombo method athe the override section of properties at CFindComboButton. Well I can only find 3 override. None of them are CreateCombo method. Well from there, you can tell that I'm lost.
I'm a noob at mfc so you might wanna take that in consideration.
Even though your question is a bit jump-led up, let me try and answer so that it works for you.
Create two class - one derived from CComboBox (call it CFindComboBox) and another from CMFCToolBarComboBoxButton (call it CFindComboBoxButton). First class will implement the Combobox that will be shown when you click the drop down button in the toolbar. This drop down button is implemented by CFindComboBoxButton. Hope this is clear.
Now define the constructor for the CFindComboBoxButton as CFindComboBoxButton(UNIT nID, int nImage, DWORD dwStyles) using three parameters as explained below:
Command ID of the button which will be ID_EDIT_FIND_COMBO (or anything you want to define it as). This will get defined in the String Table. Just add a new entry in String Table with ID_EDIT_FIND_COMBO as ID and a placeholder string. Don't omit the string value else the ID will not get defined. The string value can be anything as it wont be used anywhere.
Second parameter will just be a call to CCommandManager::GetCmdImage(ID_EDIT_FIND). This will return the default image used to show the drop down for combobox. In case you want to use your own custom image you can create one and instead pass the ID of that.
Third parameter is the styles you want to use. They are defined at http://msdn.microsoft.com/EN-US/library/7h63bxbe(v=vs.110).aspx but you can use the default value (CBS_DROPDOWNLIST) to start with.
Override the CreateCombo method of CMFCToolBarComboBoxButton and add its implementation to CFindComboBoxButton. In this method create and return a pointer to CFindComboBox (CComboBox derived class).
I hope this clears all the confusion and you should be on your way to have a custom Combobox embedded inside a toolbar.
take a look at the VisualStudioDemo Sample:
http://msdn.microsoft.com/en-us/library/bb983983%28v=vs.90%29.aspx
you can find the CFindComboButton implementation there

Regex to change method call parameter

Regexs make me cry, so, I came here for help.
I'm looking for some tips on Find & Replace in Panic's Coda. I know the F&R
is pretty advance but I'm just looking for the best way to do this.
I'm trying to rewrite a 'template engine' (very basic) I have going on with a
webapp I'm coding in PHP (CodeIgniter).
Currently I'm calling my template like so:
$this->load->view('subviews/template/headerview');
$this->load->view('subviews/template/menuview');
$this->load->view('subviews/template/sidebar');
$this->load->view('The-View-I-Want-To-Load'); // This is the important line
$this->load->view('subviews/template/footerview');
However it's inefficient using five lines of code every time I want to
load up a different page, in every different controller. So I rewrote it like this:
$data['view'] = 'The-View-I-Want-To-Load';
$this->load->view('template',$data);
That way if I need to make any major changes to the design it can
easily be done from the template.php view file (which contains the header, menu, sidebar views etc. etc.).
However I use the previous 5-lines all over the place in many
different controllers and functions. So, my question is --- How can I
find and replace the old template engine (5 lines of code) for the new
one - substituting in the name of the view in the important, unique
line for the one in $data['view]?
Does that make any sense?! If not I'll try and rephrase! I mean, is there a way of doing this via a Regex or something? Or am I on completely the wrong lines here?
your regex will look something like this :
\$this->load->view\('subviews/template/headerview'\);\n\$this->load->view\('subviews/template/menuview'\);\n\$this->load->view\('subviews/template/sidebar'\);\n\$this->load->view\('([^']*)'\);\n\$this->load->view\('subviews/template/footerview'\);
and replace with
\$data['view'] = '$1';\n\$this->load->view('template',\$data);