I am using webview to display html formatted data that is coming from database. i have tried implementing the HtmlWebViewSource to display the data but it is not displaying. Here is what i have implemented.
<WebView VerticalOptions="Fill" BackgroundColor="Red">
<WebView.Source>
<HtmlWebViewSource x:Name="surveyInstruction"/>
</WebView.Source>
</WebView>
.cs
surveyInstruction.Html = result[1][i].vchar_Instruction;
This is what i am getting from database
Question<font size="4"><b> Instruction</b></font>
i referred this post as well
Xamarin Forms control where I can show HTML formated text
What version of Xamarin.Forms are you using? I remember there were some issues like this one.
I'm using the WebView as follows (with binding) and that works fine for me.
<WebView
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand">
<WebView.Source>
<HtmlWebViewSource Html="{Binding PrivacyPolicyAsHtml}" />
</WebView.Source>
</WebView>
The PrivacyPolicyAsHtml property exists in the View Model and is assigned there.
Change VerticalOptions from "Fill" to "FillAndExpand", you should able to see the WebView or set the height for the WebView based on the requirements.
Related
I am trying to implement jQuery with PrimeFaces and JSF components, but it's not working properly. When I tried to do the same with HTML tags it;s working properly.
Here is the code with HTML tags which works properly with jQuery:
<input type="checkbox" id="check2"></input>
<h:outputText value="Check the box, if your permanent address is as same as current address."></h:outputText>
<h:message for="checkbox" style="color:red" />
with
$("#check2").change(function() {
if ($("#check2").is(":checked")) {
$("#p2").hide();
} else {
$("#p2").show();
}
});
Here is the code with PrimeFaces/JSF which doesn't work properly with jQuery:
<p:selectManyCheckbox >
<f:selectItem itemLabel="1" value="one" id="rad" ></f:selectItem>
</p:selectManyCheckbox>
with
$("#rad").change(function() {
if ($("#rad:checked").val() == "one") {
$("#p2").hide();
} else {
$("#p2").show();
}
});
You should realize that jQuery works with the HTML DOM tree in the client side. jQuery doesn't work directly on JSF components as you've written in the JSF source code, but jQuery works directly with the HTML DOM tree which is generated by those JSF components. You need to open the page in webbrowser and rightclick and then View Source. You'll see that JSF prepends the ID of the generated HTML input elements with the IDs of all parent NamingContainer components (such as <h:form>, <h:dataTable>, etc) with : as default separator character. So for example
<h:form id="foo">
<p:selectManyCheckbox id="bar" />
...
will end up in generated HTML as
<form id="foo" name="foo">
<input type="checkbox" id="foo:bar" name="foo:bar" />
...
You need to select elements by exactly that ID instead. The : is however a special character in CSS identifiers representing a pseudo selector. To select an element with a : in the ID using CSS selectors in jQuery, you need to either escape it by backslash or to use the [id=...] attribute selector or just use the old getElementById():
var $element1 = $("#foo\\:bar");
// or
var $element2 = $("[id='foo:bar']");
// or
var $element3 = $(document.getElementById("foo:bar"));
If you see an autogenerated j_idXXX part in the ID where XXX represents an incremental number, then you must give the particular component a fixed ID, because the incremental number is dynamic and is subject to changes depending on component's physical position in the tree.
As an alternative, you can also just use a class name:
<x:someInputComponent styleClass="someClassName" />
which ends up in HTML as
<input type="..." class="someClassName" />
so that you can get it as
var $elements = $(".someClassName");
This allows for better abstraction and reusability. Surely those kind of elements are not unique. Only the main layout elements like header, menu, content and footer are really unique, but they are in turn usually not in a NamingContainer already.
As again another alternative, you could just pass the HTML DOM element itself into the function:
<x:someComponent onclick="someFunction(this)" />
function someFunction(element) {
var $element = $(element);
// ...
}
See also:
How can I know the id of a JSF component so I can use in Javascript
How to use JSF generated HTML element ID with colon ":" in CSS selectors?
By default, JSF generates unusable IDs, which are incompatible with the CSS part of web standards
Integrate JavaScript in JSF composite component, the clean way
You also can use the jQuery "Attribute Contains Selector" (here is the url http://api.jquery.com/attribute-contains-selector/)
For example If you have a
<p:spinner id="quantity" value="#{toBuyBean.quantityToAdd}" min="0"/>
and you want to do something on its object you can select it with
jQuery('input[id*="quantity"]')
and if you want to print its value you can do this
alert(jQuery('input[id*="quantity"]').val());
In order to know the real html tag of the element you can always look at the real html element (in this case spinner was translated into input) using firebug or ie developer tools or view source...
Daniel.
If you're using RichFaces you can check rich:jQuery comonent. It allows you to specify server side id for jQuery component. For example, you have component with specified server id, then you can apply any jQuery related stuff to in next way:
<rich:jQuery selector="#<server-side-component-id>" query="find('.some-child').removeProp('style')"/>
For more info, please check doumentation.
Hope it helps.
look this will help you when i select experience=Yes my dialoguebox which id is dlg3 is popup.and if value is No it will not open
I am using Xamarin Forms 2.3.2.127 for development of a mobile application.
I have an activity indicator that sits within a StackLayout, which is in turn contained within a Grid Row.
The activity indicator renders on Android, however does not render on iOS.
The controls XAML is as follows:
<ActivityIndicator WidthRequest="50" Color="Red" HeightRequest="50" VerticalOptions="Center" IsVisible="True" IsRunning="True"/>
There are no bindings applied at present, and there have been no changes to the underlying control using CustomRenderers.
Any ideas on what could be causing this issue, or if there are any common bugs? This has occured before in other projects and rectified itself without any changes randomly.
I had same problem & not visible during operation, I m using MVVM Binding, I solved it by invoking the MainThread
XAML
<ActivityIndicator IsVisible="{Binding PBVisibility}" IsRunning="{Binding PBRunning}" Color="Black" />
ViewModel
Device.BeginInvokeOnMainThread (() => {
PBVisibility = true;
PBRunning = true;
RaisePropertyChanged ("PBVisibility");
RaisePropertyChanged ("PBRunning");
});
You run that in MainThread & it will work.
My html code is as follows
<p:graphicImage id="graphImg" value="#{imageMB.img1}" width="740" height="480"
cache="false" />
<p:commandButton type="submit" value="Next" process="#all"
action="#{imageMB.nextImg()}"
update=":mainFORM:graphImg"/>
Note:In the above code i have tried most of the options for Process (#this,#form,...)
In by Bean i basically pass the StreamedContent
public void nextImg(){
img1=new streamed content;
}
Note: My images are not stored in the project location/glassfish its stored in /Test folder.
When i click the next button actually the img1 data changes, but the image in p:graphicsImage remains same.
The same works fine if i refresh the whole page (using F5 or javascript).
I really don't know why it doesn't get refreshed from the update command but works when the page is reloaded.
I use Primeface4.0/Glassfish 3.1.2.2
There is a issue with updating p:graphicimage on PrimeFaces 4.0 public version. Take a look at the offical forum: http://forum.primefaces.org/viewtopic.php?f=3&t=34658
I'm implementing some kind of frontend editor in my web page, using rich:editor. When clicking a link, the editor should open, and after saving editor's content, the editor should close again. I'm having trouble with onsave event for closing the editor. Here is my code.
This is the link that opens the editor, due to setting the property bean.show to true. It works ok:
<h:commandLink>
...
<f:setPropertyActionListener value="true" target="#{bean.show}" />
</h:commandLink>
This is the editor itself, only rendered when show evaluates to true:
<h:form>
<rich:editor value="..." onsave="showEditor(false)" rendered="#{bean.show}" />
</h:form>
The onsave event should close the editor by setting the show property to false again, but the editor stays open, because showEditor() is not called:
<a4j:jsFunction name="showEditor">
<a4j:param name="param1" assignTo="#{bean.show}" />
</a4j:jsFunction>
Am I doing something completely wrong? Or do you have any other ideas how to realize this? Any help is appreciated.
just double-checked: in version richfaces 4.x, there is no onsave attribute at all, but
oninit
onblur
onfocus
ondirty
onchange
like pointed out in the org.richfaces.component.UIEditor class. The same is true, if you want to use f:ajax to ajaxify the editor.
Right now, the "save"-icon in the editor just sends a form.submit() or something. So either try to add your jsFunction on that event or to introduce an own save-button.
Edit: Richfaces 4 uses the javascript based CKEditor, so if you want to overwrite their "save"-button, this forum entry regarding CKEditor's save implementation might be of your help.
Also a valueChangeListener might be a possibility solution to trigger your Bean.setShow(boolean show) property.
xhtml:
<rich:editor value="#{bean.editorValue}"
valueChangeListener="#{bean.valueChanged}" />
method in managed bean:
public void valueChanged(ValueChangeEvent e) {
// do the code to close the window here
}
The valueChangeListener also works in Richfaces 4.3, but maybe starting within the javascript of the CKEditor is the better choice.
Hope, that helps... L.
I'm having a problem with this this XAML... When I run it, it hangs because of the TextBox. (By "hangs" I mean that the hosting aspx page shows in the browser, but the usercontrol object will not appear on the page, and there are some little green bars in the bottom of the Internet Explorer window that fill up but never go away.) I have both a TextBox and a TextBlock in my code just for testing. It runs fine if I comment out the TextBox and leave only the TextBlock, so I know the DataContext is getting set and the binding to PatternName does work. There are no errors in the Output window to help me debug. Please help! I've spent hours on this problem. What can possible be happening?
<StackPanel x:Name="HolePatternStackPanel" >
<TextBlock Text="{Binding PatternName}" Width="75" />
<TextBox Text="{Binding PatternName}" Height="25" Width="125"/>
</StackPanel>
Here is the code that sets the DataContext from a calling ListBox.SelectionChanged method:
private void lvHolePatterns_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
HolePatternStackPanel.DataContext = this.ActivePattern;
}
Well, I've learned more about this... This whole thing is a Master-Detail UI design, and so I had my ListBox using SelectedItem="{Binding ActivePattern}", and apparently, some infinite loop was getting set up between that and the SelectionChanged eventhandler.
So now my question now becomes what good is SelectedItem anyway? Since I had to add a SelectionChanged eventhandler to update the DataContext of the detail stack panel?
You wouldn't need to use the SelectionChanged event if you set the DataContext of the controls with the SelectedItem
for example
<Grid DataContext="{Binding SelectedItem}">
<TextBlock Text="{Binding some_field_in_selecteditem}" />
</Grid>