Search Results

Search found 3221 results on 129 pages for 'inline styles'.

Page 116/129 | < Previous Page | 112 113 114 115 116 117 118 119 120 121 122 123  | Next Page >

  • Regular expression from font to span (size and colour) and back (VB.NET)

    - by chapmanio
    Hi, I am looking for a regular expression that can convert my font tags (only with size and colour attributes) into span tags with the relevant inline css. This will be done in VB.NET if that helps at all. I also need a regular expression to go the other way as well. To elaborate below is an example of the conversion I am looking for: <font size="10">some text</font> To then become: <span style="font-size:10px;">some text</span> So converting the tag and putting a "px" at the end of whatever the font size is (I don't need to change/convert the font size, just stick px at the end). The regular expression needs to cope with a font tag that only has a size attribute, only a color attribute, or both: <font size="10">some text</font> <font color="#000000">some text</font> <font size="10" color="#000000">some text</font> <font color="#000000" size="10">some text</font> I also need another regular expression to do the opposite conversion. So for example: <span style="font-size:10px;">some text</span> Will become: <font size="10">some text</font> As before converting the tag but this time removing the "px", I don't need to worry about changing the font size. Again this will also need to cope with the size styling, font styling, and a combination of both: <span style="font-size:10px;">some text</span> <span style="color:#000000;">some text</span> <span style="font-size:10px; color:#000000;">some text</span> <span style="color:#000000; font-size:10px;">some text</span> I apprecitate this is a lot to ask, I am hopeless with regular expressions and need to find a way of making these conversions in my code. Thanks so much to anyone that can/is willing to help me!

    Read the article

  • Between-request Garbage Collection using Passenger

    - by raphaelcm
    We're using Rails 3.0.7 and REE 1.8.7. Long-term, we will be upgrading, but at the moment it's not feasible. Following the advice of several blog posts, we've been tuning our GC, and have settings that work pretty well. But we would really like to run GC outside of the request-response cycle. I've tried patching Passenger per this post, and using the code supplied in this SO question. In both cases, GC does indeed happen between requests. However, every time the between-request GC happens, I see a bunch of this: MONGODB [INFO] Connecting... MONGODB admin['$cmd'].find({:ismaster=>1}).limit(-1) MONGODB admin['$cmd'].find({:ismaster=>1}).limit(-1) MONGODB admin['$cmd'].find({:ismaster=>1}).limit(-1) Starting the New Relic Agent. Installed New Relic Browser Monitoring middleware SQL (0.0ms) SHOW TABLES SQL (0.0ms) SHOW TABLES RefinerySetting Load (0.0ms) SELECT `refinery_settings`.* FROM `refinery_settings` WHERE `refinery_settings`.`scoping` = 'pages' AND `refinery_settings`.`name` = 'use_marketable_urls' LIMIT 1 SQL (0.0ms) BEGIN RefinerySetting Load (0.0ms) SELECT `refinery_settings`.* FROM `refinery_settings` WHERE `refinery_settings`.`id` = 1 LIMIT 1 AREL (0.0ms) UPDATE `refinery_settings` SET `value` = '--- \"false\"\n', `callback_proc_as_string` = NULL WHERE `refinery_settings`.`id` = 1 SQL (0.0ms) SHOW TABLES RefinerySetting Load (0.0ms) SELECT `refinery_settings`.* FROM `refinery_settings` SQL (0.0ms) COMMIT SQL (0.0ms) SHOW TABLES RefinerySetting Load (4.0ms) SELECT `refinery_settings`.* FROM `refinery_settings` WHERE `refinery_settings`.`scoping` IS NULL AND `refinery_settings`.`name` = 'user_image_sizes' LIMIT 1 SQL (0.0ms) BEGIN RefinerySetting Load (0.0ms) SELECT `refinery_settings`.* FROM `refinery_settings` WHERE `refinery_settings`.`id` = 17 LIMIT 1 AREL (0.0ms) UPDATE `refinery_settings` SET `value` = '--- \n:small: 120x120>\n:medium: 280x280>\n:large: 580x580>\n', `callback_proc_as_string` = NULL WHERE `refinery_settings`.`id` = 17 SQL (0.0ms) SHOW TABLES RefinerySetting Load (0.0ms) SELECT `refinery_settings`.* FROM `refinery_settings` SQL (0.0ms) COMMIT ******** Engine Extend: app/helpers/blog_posts_helper SQL (0.0ms) SHOW TABLES SQL (0.0ms) SHOW TABLES SQL (0.0ms) SHOW TABLES SQL (4.0ms) SHOW TABLES SQL (0.0ms) SHOW TABLES SQL (0.0ms) SHOW TABLES SQL (0.0ms) SHOW TABLES ******** Engine Extend: app/models/user SQL (0.0ms) describe `roles_users` SQL (0.0ms) SHOW TABLES SQL (0.0ms) SHOW TABLES SQL (4.0ms) describe `roles_users` SQL (0.0ms) SHOW TABLES SQL (4.0ms) SHOW TABLES SQL (0.0ms) SHOW TABLES SQL (0.0ms) SHOW TABLES (etc, etc, etc) Which is what happens when rails "loads the world" when the app starts up. Basically, GC.start is re-loading the app for some reason. Because of this, between-request GC is much slower than inline GC. Is there a way around this? I would love to have snappy, between-request GC if possible. Thanks.

    Read the article

  • C++ HW - defining classes - objects that have objects of other class problem in header file (out of

    - by kitfuntastik
    This is my first time with much of this code. With this instancepool.h file below I get errors saying I can't use vector (line 14) or have instance& as a return type (line 20). It seems it can't use the instance objects despite the fact that I have included them. #ifndef _INSTANCEPOOL_H #define _INSTANCEPOOL_H #include "instance.h" #include <iostream> #include <string> #include <vector> #include <stdlib.h> using namespace std; class InstancePool { private: unsigned instances;//total number of instance objects vector<instance> ipp;//the collection of instance objects, held in a vector public: InstancePool();//Default constructor. Creates an InstancePool object that contains no Instance objects InstancePool(const InstancePool& original);//Copy constructor. After copying, changes to original should not affect the copy that was created. ~InstancePool();//Destructor unsigned getNumberOfInstances() const;//Returns the number of Instance objects the the InstancePool contains. const instance& operator[](unsigned index) const; InstancePool& operator=(const InstancePool& right);//Overloading the assignment operator for InstancePool. friend istream& operator>>(istream& in, InstancePool& ip);//Overloading of the >> operator. friend ostream& operator<<(ostream& out, const InstancePool& ip);//Overloading of the << operator. }; #endif Here is the instance.h : #ifndef _INSTANCE_H #define _INSTANCE_H ///////////////////////////////#include "instancepool.h" #include <iostream> #include <string> #include <stdlib.h> using namespace std; class Instance { private: string filenamee; bool categoryy; unsigned featuress; unsigned* featureIDD; unsigned* frequencyy; string* featuree; public: Instance (unsigned features = 0);//default constructor unsigned getNumberOfFeatures() const; //Returns the number of the keywords that the calling Instance object can store. Instance(const Instance& original);//Copy constructor. After copying, changes to the original should not affect the copy that was created. ~Instance() { delete []featureIDD; delete []frequencyy; delete []featuree;}//Destructor. void setCategory(bool category){categoryy = category;}//Sets the category of the message. Spam messages are represented with true and and legit messages with false.//easy bool getCategory() const;//Returns the category of the message. void setFileName(const string& filename){filenamee = filename;}//Stores the name of the file (i.e. “spam/spamsga1.txt”, like in 1st assignment) in which the message was initially stored.//const string& trick? string getFileName() const;//Returns the name of the file in which the message was initially stored. void setFeature(unsigned i, const string& feature, unsigned featureID,unsigned frequency) {//i for array positions featuree[i] = feature; featureIDD[i] = featureID; frequencyy[i] = frequency; } string getFeature(unsigned i) const;//Returns the keyword which is located in the ith position.//const string unsigned getFeatureID(unsigned i) const;//Returns the code of the keyword which is located in the ith position. unsigned getFrequency(unsigned i) const;//Returns the frequency Instance& operator=(const Instance& right);//Overloading of the assignment operator for Instance. friend ostream& operator<<(ostream& out, const Instance& inst);//Overloading of the << operator for Instance. friend istream& operator>>(istream& in, Instance& inst);//Overloading of the >> operator for Instance. }; #endif Also, if it is helpful here is instance.cpp: // Here we implement the functions of the class apart from the inline ones #include "instance.h" #include <iostream> #include <string> #include <stdlib.h> using namespace std; Instance::Instance(unsigned features) { //Constructor that can be used as the default constructor. featuress = features; if (features == 0) return; featuree = new string[featuress]; // Dynamic memory allocation. featureIDD = new unsigned[featuress]; frequencyy = new unsigned[featuress]; return; } unsigned Instance::getNumberOfFeatures() const {//Returns the number of the keywords that the calling Instance object can store. return featuress;} Instance::Instance(const Instance& original) {//Copy constructor. filenamee = original.filenamee; categoryy = original.categoryy; featuress = original.featuress; featuree = new string[featuress]; for(unsigned i = 0; i < featuress; i++) { featuree[i] = original.featuree[i]; } featureIDD = new unsigned[featuress]; for(unsigned i = 0; i < featuress; i++) { featureIDD[i] = original.featureIDD[i]; } frequencyy = new unsigned[featuress]; for(unsigned i = 0; i < featuress; i++) { frequencyy[i] = original.frequencyy[i];} } bool Instance::getCategory() const { //Returns the category of the message. return categoryy;} string Instance::getFileName() const { //Returns the name of the file in which the message was initially stored. return filenamee;} string Instance::getFeature(unsigned i) const { //Returns the keyword which is located in the ith position.//const string return featuree[i];} unsigned Instance::getFeatureID(unsigned i) const { //Returns the code of the keyword which is located in the ith position. return featureIDD[i];} unsigned Instance::getFrequency(unsigned i) const { //Returns the frequency return frequencyy[i];} Instance& Instance::operator=(const Instance& right) { //Overloading of the assignment operator for Instance. if(this == &right) return *this; delete []featureIDD; delete []frequencyy; delete []featuree; filenamee = right.filenamee; categoryy = right.categoryy; featuress = right.featuress; featureIDD = new unsigned[featuress]; frequencyy = new unsigned[featuress]; featuree = new string[featuress]; for(unsigned i = 0; i < featuress; i++) { featureIDD[i] = right.featureIDD[i]; } for(unsigned i = 0; i < featuress; i++) { frequencyy[i] = right.frequencyy[i]; } for(unsigned i = 0; i < featuress; i++) { featuree[i] = right.featuree[i]; } return *this; } ostream& operator<<(ostream& out, const Instance& inst) {//Overloading of the << operator for Instance. out << endl << "<message file=" << '"' << inst.filenamee << '"' << " category="; if (inst.categoryy == 0) out << '"' << "legit" << '"'; else out << '"' << "spam" << '"'; out << " features=" << '"' << inst.featuress << '"' << ">" <<endl; for (int i = 0; i < inst.featuress; i++) { out << "<feature id=" << '"' << inst.featureIDD[i] << '"' << " freq=" << '"' << inst.frequencyy[i] << '"' << "> " << inst.featuree[i] << " </feature>"<< endl; } out << "</message>" << endl; return out; } istream& operator>>(istream& in, Instance& inst) { //Overloading of the >> operator for Instance. string word; string numbers = ""; string filenamee2 = ""; bool categoryy2 = 0; unsigned featuress2; string featuree2; unsigned featureIDD2; unsigned frequencyy2; unsigned i; unsigned y; while(in >> word) { if (word == "<message") {//if at beginning of message in >> word;//grab filename word for (y=6; word[y]!='"'; y++) {//pull out filename from between quotes filenamee2 += word[y];} in >> word;//grab category word if (word[10] == 's') categoryy2 = 1; in >> word;//grab features word for (y=10; word[y]!='"'; y++) { numbers += word[y];} featuress2 = atoi(numbers.c_str());//convert string of numbers to integer Instance tempp2(featuress2);//make a temporary Instance object to hold values read in tempp2.setFileName(filenamee2);//set temp object to filename read in tempp2.setCategory(categoryy2); for (i=0; i<featuress2; i++) {//loop reading in feature reports for message in >> word >> word >> word;//skip two words numbers = "";//reset numbers string for (int y=4; word[y]!='"'; y++) {//grab feature ID numbers += word[y];} featureIDD2 = atoi(numbers.c_str()); in >> word;// numbers = ""; for (int y=6; word[y]!='"'; y++) {//grab frequency numbers += word[y];} frequencyy2 = atoi(numbers.c_str()); in >> word;//grab actual feature string featuree2 = word; tempp2.setFeature(i, featuree2, featureIDD2, frequencyy2); }//all done reading in and setting features in >> word;//read in last part of message : </message> inst = tempp2;//set inst (reference) to tempp2 (tempp2 will be destroyed at end of function call) return in; } } } and instancepool.cpp: // Here we implement the functions of the class apart from the inline ones #include "instancepool.h" #include "instance.h" #include <iostream> #include <string> #include <vector> #include <stdlib.h> using namespace std; InstancePool::InstancePool()//Default constructor. Creates an InstancePool object that contains no Instance objects { instances = 0; ipp.clear(); } InstancePool::~InstancePool() { ipp.clear();} InstancePool::InstancePool(const InstancePool& original) {//Copy constructor. instances = original.instances; for (int i = 0; i<instances; i++) { ipp.push_back(original.ipp[i]); } } unsigned InstancePool::getNumberOfInstances() const {//Returns the number of Instance objects the the InstancePool contains. return instances;} const Instance& InstancePool::operator[](unsigned index) const {//Overloading of the [] operator for InstancePool. return ipp[index];} InstancePool& InstancePool::operator=(const InstancePool& right) {//Overloading the assignment operator for InstancePool. if(this == &right) return *this; ipp.clear(); instances = right.instances; for(unsigned i = 0; i < instances; i++) { ipp.push_back(right.ipp[i]); } return *this; } istream& operator>>(istream& in, InstancePool& ip) {//Overloading of the >> operator. ip.ipp.clear(); string word; string numbers; int total;//int to hold total number of messages in collection while(in >> word) { if (word == "<messagecollection"){ in >> word;//reads in total number of all messages for (int y=10; word[y]!='"'; y++){ numbers = ""; numbers += word[y]; } total = atoi(numbers.c_str()); for (int x = 0; x<total; x++) {//do loop for each message in collection in >> ip.ipp[x];//use instance friend function and [] operator to fill in values and create Instance objects and read them intot he vector } } } } ostream& operator<<(ostream& out, const InstancePool& ip) {//Overloading of the << operator. out << "<messagecollection messages=" << '"' << '>' << ip.instances << '"'<< endl << endl; for (int z=0; z<ip.instances; z++) { out << ip[z];} out << endl<<"</messagecollection>\n"; } This code is currently not writing to files correctly either at least, I'm sure it has many problems. I hope my posting of so much is not too much, and any help would be very much appreciated. Thanks!

    Read the article

  • Routing error when trying to use same view for update and create flows (Rails 3)

    - by Jamis Charles
    My overall use case: I have a Listing model that has many images. The Listing detail page lists all the fields that can be updated inline (through ajax). I want to be able to use the same view for both update listing and create new listing. My listing controller looks as follows: def detail @listing = Listing.find(params[:id]) @image = Image.new #should this link somewhere else? respond_to do |format| format.html # show.html.erb format.xml { render :xml => @listing } end end def create # create a new listing and save it immediately. Assign it to guest, with a status of "draft" @listing = Listing.new(:price_id => 1) # Default price id # save it to db # TODO add validation that it has to have a price ID, on record creation. So the view doesn't break. @listing.save @image = Image.new # redirect_to "/listings/detail/@listing.id" #this didn't work respond_to do |format| format.html # show.html.erb format.xml { render :xml => @listing } end end The PROBLEM I'm using a partial that shows the same form for the create view and the detail view. This works perfectly except for one thing: When I pull up http://0.0.0.0:3000/listings/detail/7, it works perfectly. When I pull up http://0.0.0.0:3000/listings/new, I get the following error: Showing /Applications/MAMP/htdocs/rails_testing/feedbackd/app/views/listings/_edit_form.html.erb where line #100 raised: No route matches {:action="show", :controller="images"} Extracted source (around line #100): 97: <!-- Form for new images --> 98: <div class="span-20 append-bottom"> 99: <!-- <%# form_for :image, @image, :url => image_path, :html => { :multipart => true } do |f| %> --> 100: <%= form_for @image, :url => image_path, :html => { :multipart => true } do |f| %> 101: <%= f.text_field :description %><br /> 102: <%= f.file_field :photo %> 103: <%= submit_tag "Upload" %> What I think the issue is: When I upload a new image (I'm using Paperclip), it requires the listing_id to create the image record. Since the listing_id isn't passed in with listings/new it can't find the listing_id. How can I pass in the id? Via a redirect? What's the best way to solve this? Thank you.

    Read the article

  • How to store multiple scroll positions for scrolling div element depending on active View in MultiView (asp.net webform

    - by Spence
    confusing title but the best way I can put it. Basically I am currently using a single div with overflow:auto that contains different GridViews. The GridViews are swapped by using a MultiView with each indiviudal view containing a single GridView. I would like to be able to store the scroll position of each view so that I can set the div's scroll position depending on the view that will be switched to. Here is how my page is set up. <div id="scrollingDiv" style="height:100%; overflow:auto;"> <div id="gridWrap"> <asp:UpdatePanel ID="UpdatePanel1" runat="server" RenderMode="Inline"> <ContentTemplate> <asp:MultiView ID="MultiView1" runat="server"> <asp:View ID="view1" runat="server"> <asp:GridView ID="gridView1" runat="server"> </asp:GridView> </asp:View> <asp:View ID="view2" runat="server"> <asp:GridView ID="gridView2" runat="server"> </asp:GridView> </asp:View> </asp:Multiview> </ContentTemplate> </asp:UpdatePanel> </div> </div> So scrollingDiv will contain all the Views and will scroll for each one of the GridViews. To switch between views I have a drop down connected to an protected void DropDownList_SelectedIndexChanged(object sender, EventArgs e) { switch (DownList.SelectedItem.Value) { case "view1": MultiView1.SetActiveView(view1); break; case "view2": MultiView1.SetActiveView(view2); break; } } I have been looking around and can't quite find something specific to my case. I would like to be able to use just the one overflow div but would understand if I had to make a separate overflow div for each view. Any help would be great, Thanks.

    Read the article

  • Hot to get rid of memory allocations/deallocations in swig wrappers?

    - by Dmitriy Matveev
    I want to use swig for generation of read-only wrappers for a complex object. The object which I want to wrap will always be existent while I will read it. And also I will only use my wrappers at the time that object is existent, thus I don't need any memory management from SWIG. For following swig interface: %module test %immutable; %inline %{ struct Foo { int a; }; struct Bar { int b; Foo f; }; %} I will have a wrappers which will have a lot of garbage in generated interfaces and do useless work which will reduce performance in my case. Generated java wrapper for Bar class will be like this: public class Bar { private long swigCPtr; protected boolean swigCMemOwn; protected Bar(long cPtr, boolean cMemoryOwn) { swigCMemOwn = cMemoryOwn; swigCPtr = cPtr; } protected static long getCPtr(Bar obj) { return (obj == null) ? 0 : obj.swigCPtr; } protected void finalize() { delete(); } public synchronized void delete() { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; testJNI.delete_Bar(swigCPtr); } swigCPtr = 0; } } public int getB() { return testJNI.Bar_b_get(swigCPtr, this); } public Foo getF() { return new Foo(testJNI.Bar_f_get(swigCPtr, this), true); } public Bar() { this(testJNI.new_Bar(), true); } } I don't need 'swigCMemOwn' field in my wrapper since it always will be false. All code related to this field will also be useless. There are also unnecessary logic in native code: SWIGEXPORT jlong JNICALL Java_some_testJNI_Bar_1f_1get(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) { jlong jresult = 0 ; struct Bar *arg1 = (struct Bar *) 0 ; Foo result; (void)jenv; (void)jcls; (void)jarg1_; arg1 = *(struct Bar **)&jarg1; result = ((arg1)->f); { Foo * resultptr = (Foo *) malloc(sizeof(Foo)); memmove(resultptr, &result, sizeof(Foo)); *(Foo **)&jresult = resultptr; } return jresult; } I don't need these calls to malloc and memmove. I want to force swig to resolve both of these problems, but don't know how. Is it possible?

    Read the article

  • Messing with the stack in assembly and c++

    - by user246100
    I want to do the following: I have a function that is not mine (it really doesn't matter here but just to say that I don't have control over it) and that I want to patch so that it calls a function of mine, preserving the arguments list (jumping is not an option). What I'm trying to do is, to put the stack pointer as it was before that function is called and then call mine (like going back and do again the same thing but with a different function). This doesn't work straight because the stack becomes messed up. I believe that when I do the call it replaces the return address. So, I did a step to preserve the return address saving it in a globally variable and it works but this is not ok because I want it to resist to recursitivy and you know what I mean. Anyway, i'm a newbie in assembly so that's why I'm here. Please, don't tell me about already made software to do this because I want to make things my way. Of course, this code has to be compiler and optimization independent. My code (If it is bigger than what is acceptable please tell me how to post it): // A function that is not mine but to which I have access and want to patch so that it calls a function of mine with its original arguments void real(int a,int b,int c,int d) { } // A function that I want to be called, receiving the original arguments void receiver(int a,int b,int c,int d) { printf("Arguments %d %d %d %d\n",a,b,c,d); } long helper; // A patch to apply in the "real" function and on which I will call "receiver" with the same arguments that "real" received. __declspec( naked ) void patch() { _asm { // This first two instructions save the return address in a global variable // If I don't save and restore, the program won't work correctly. // I want to do this without having to use a global variable mov eax, [ebp+4] mov helper,eax push ebp mov ebp, esp // Make that the stack becomes as it were before the real function was called add esp, 8 // Calls our receiver call receiver mov esp, ebp pop ebp // Restores the return address previously saved mov eax, helper mov [ebp+4],eax ret } } int _tmain(int argc, _TCHAR* argv[]) { FlushInstructionCache(GetCurrentProcess(),&real,5); DWORD oldProtection; VirtualProtect(&real,5,PAGE_EXECUTE_READWRITE,&oldProtection); // Patching the real function to go to my patch ((unsigned char*)real)[0] = 0xE9; *((long*)((long)(real) + sizeof(unsigned char))) = (char*)patch - (char*)real - 5; // calling real function (I'm just calling it with inline assembly because otherwise it seems to works as if it were un patched // that is strange but irrelevant for this _asm { push 666 push 1337 push 69 push 100 call real add esp, 16 } return 0; }

    Read the article

  • How to align Definition Lists in IE6 ?

    - by ellander
    I'm having a major headache trying to align some and elements in ie6. It looks fine in ie7 and firefox but the dt elements don't appear in ie6. can anyone help? here is the code.. <div id="listMembers"> <h3>Members</h3> <dl class="myDL"> <dt>Name</dt> <dd>John Smith</dd> <dt>Address</dt> <dd>the street</dd> ... </dl> <div id="listOptions"> <div> <table>...</table> </div> </div> <div> and the css:- DL.myDL { BORDER-RIGHT: black 2px outset; PADDING-RIGHT: 2px; BORDER-TOP: black 2px outset; DISPLAY: block; PADDING-LEFT: 2px; BACKGROUND: #ccbe99; PADDING-BOTTOM: 2px; BORDER-LEFT: black 2px outset; WIDTH: auto; PADDING-TOP: 2px; BORDER-BOTTOM: black 2px outset; FONT-FAMILY: "Trebuchet MS", Arial, sans-serif } DL.myDL DT { CLEAR: both; PADDING-RIGHT: 3px; DISPLAY: inline; FLOAT: left; WIDTH: 250px; TEXT-ALIGN: right } I basically want the dt text aligned to the right and the dd on the right hand side with left align text. I reset the margin on all elements to be 0 before anything else in the css and the elements are within a dive with position relative.

    Read the article

  • form inside tabview doesn't work

    - by user3536737
    i am working with jsf and primefaces , and here is what 've tried well i want to creat a tabview that get data from an arraylist in my bean i get for exemple 4 tabs , and inside each one i've created a hidden panel where i have a form with 2 input text to update informations , do i display the panel when i click on the second button Update , after that my panel is not hidden anymore , and i set the new values and click on the second button to update the informations , the problem is that the updating and the execution is working only for the first tab , it means when i try to update the new informations it works for the first one and for the other tabs it doesn't here is the code <p:tab title="#{rr.nom_ressource}"> <h:panelGrid> <h:graphicImage value="Ressources/images/emp.jpg" style="vertical-align:middle" /> <span style="font-size:15px; width:170px; display:inline-block;"> Nom : #{rr.nom_ressource} Type: #{rr.type_ressource} Specification: #{rr.experience} </span> <h:commandButton image="Ressources/images/delete.jpg" actionListener="#{SelectBean.act}" update=":form" style="vertical-align:middle" > Update </h:commandButton> <h:commandButton update=":outPanel" actionListener="#{SelectBean.mod1()}" image="Ressources/images/update.png" style="vertical-align:middle" > Modifier </h:commandButton> <h:form id="form111"> <p:growl id="growl" showDetail="true" sticky="true" /> <p:panel rendered ="#{SelectBean.bol}" closable="true" toggleable="true" id="outPanel" styleClass="outPanel" widgetVar="outpanel"> <h:outputLabel value="Nom " /> <h:inputText value="#{SelectBean.nom}" /> <br/> <h:outputLabel value="Experience " /> <h:inputText value="#{SelectBean.exp}" /> <br/> <h:commandButton value="Update" action="#{SelectBean.done}"/> </p:panel> </h:form> </h:panelGrid> </p:tab> for my managedbean the code is correct i think the problem is here

    Read the article

  • IE8 ignores absolute positioning and margin:auto

    - by tuff
    I have a lightbox-style div with scrolling content that I am trying to restrict to a reasonable size within the viewport. I also want this div to be horizontally centered. This is all easy in Fx/Chrome/IE9. My problem is that IE8 ignores the absolute positioning which I use to size the content, and the rule margin: 0 auto which I use to horizontally center the lightbox. 1) Why? 2) What are my options for workarounds? EDIT: The centering issue is fixed by setting text-align:center on the parent element, but I have no idea why that works since the element I want to center is not inline. Still stuck on the absolute positioning stuff. HTML: <div class="bg"> <div class="a"> <div class="aa">titlebar</div> <div class="b"> <!-- many lines of content here --> </div> </div> </div> CSS: body { overflow: hidden; height: 100%; margin: 0; padding: 0; } /* IE8 needs ruleset above */ .bg { background: #333; position: fixed; top: 0; right: 0; bottom: 0; left: 0; height: 100%; /* needed in IE8 or the bg will only be as tall as the lightbox */ } .a { background: #eee; border: 3px solid #000; height: 80%; max-height: 800px; min-height: 200px; margin: 0 auto; position: relative; width: 80%; min-width: 200px; max-width: 800px; } .aa { background: lightblue; height: 28px; line-height: 28px; text-align: center; } .b { background: coral; overflow: auto; padding: 20px; position: absolute; top: 30px; right: 0; bottom: 0; left: 0; } Here's a demo of the problem: http://jsbin.com/urikoj/1/edit

    Read the article

  • ruby on rails photo upload problem

    - by dodo00700
    Hallo rails version 2.3.5 I'm learning rails and I run into a problem. I'm doing some nesting forms from the railscasts tutorials. I changed the text area into a data field to upload photos and everything is working. Now i have to display the uploaded pictures and i simply can't do it. I Tried everything I could find on the net but nothing worked. PROBLEM I have the Article controller which handles the article CRUD. inside the article new form there is nested a form for uploading images. article controller def code_image @image_data = Photo.find(params[:id]) @image = @image_data.binary_data send_data(@image, :type => @image_data.content_type, :filename => @image_data.filename, :disposition => 'inline') end photo model def image_file=(input_data) self.filename = input_data.original_filename self.content_type = input_data.content_type.chomp self.binary_data = input_data.read end articles/show.html.erb <%=h @article.title %> <%=h @article.body %> <% for photos in @article.photos %> <%= image_tag(url_for({:action => 'code_image', :id => @article.photos.id})) -%> <% end %> articles/_formnew.html.erb <% form_for (:article, @article, :url => {:action=>'create'}, :html=> {:multipart=>true}) do |f| %> <%= f.error_messages % <%= f.label :title %><br /> <%= f.text_field :title %><br /><br /> <%= f.label :body %><br /> <%= f.text_area :body, :style => 'width: 600px;' %><br /><br /> <% f.fields_for :photos do |builder|%> <%= builder.label :content, "Photo"%><br /> <%= builder.file_field :image_file %><br /> <% end %> <br /> <%= f.submit "Create" %> <% end % Thanks

    Read the article

  • Inlining an array of non-default constructible objects in a C++ class

    - by porgarmingduod
    C++ doesn't allow a class containing an array of items that are not default constructible: class Gordian { public: int member; Gordian(int must_have_variable) : member(must_have_variable) {} }; class Knot { Gordian* pointer_array[8]; // Sure, this works. Gordian inlined_array[8]; // Won't compile. Can't be initialized. }; As even beginner C++ users know, the language guarantees that all members are initialized when constructing a class. And it doesn't trust the user to initialize everything in the constructor - one has to provide valid arguments to the constructors of all members before the body of the constructor even starts. Generally, that's a great idea as far as I'm concerned, but I've come across a situation where it would be a lot easier if I could actually have an array of non-default constructible objects. The obvious solution: Have an array of pointers to the objects. This is not optimal in my case, as I am using shared memory. It would force me to do extra allocation from an already contended resource (that is, the shared memory). The entire reason I want to have the array inlined in the object is to reduce the number of allocations. This is a situation where I would be willing to use a hack, even an ugly one, provided it works. One possible hack I am thinking about would be: class Knot { public: struct dummy { char padding[sizeof(Gordian)]; }; dummy inlined_array[8]; Gordian* get(int index) { return reinterpret_cast<Gordian*>(&inlined_array[index]); } Knot() { for (int x = 0; x != 8; x++) { new (get(x)) Gordian(x*x); } } }; Sure, it compiles, but I'm not exactly an experienced C++ programmer. That is, I couldn't possibly trust my hacks less. So, the questions: 1) Does the hack I came up with seem workable? What are the issues? (I'm mainly concerned with C++0x on newer versions of GCC). 2) Is there a better way to inline an array of non-default constructible objects in a class?

    Read the article

  • Help with doctype issues

    - by James
    Hi I am having issues making my footer stick to the bottom of the page in all browsers. I have the following document structure: <html> <head> </head> <body> <div id="wrapper"> <div id="header"> <ul> <li>home</li> </ul> </div> <div class="expander"></div> </div> <div id="footer" class="expander"> </div> </body> </html> Relevant CSS is: body { margin: 0; height: 100%; } #wrapper { min-height: 100%; height: auto !important; height: 100%; margin: 0 auto -116px; } .expander { height: 116px; } #footer { width: 100%; } #header ul { list-style: none outside none; clear: both; margin: 0; } #header li { margin: 0; margin-right: 20px; padding: 0; display: inline-block; height: 85px; padding-top: 20px; margin-bottom: -20px; } When used without any doc type, the page renders as I intend it to in Chrome and Firefox. In IE8, however, the list item tabs are on separate lines When I add an XHTML doctype, the page renders correctly in IE8 except the footer is not drawn at the bottom of the page in IE8, Chrome or Firefox, i.e. the footer sits directly below the menu bar. Example doctype: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> What am I doing wrong?

    Read the article

  • Class Template Instantiation: any way round this circular reference?

    - by TimYorke34
    I have two classes that I'm using to represent some hardware: A Button and an InputPin class which represent a button that will change the value of an IC's input pin when it's pressed down. A simple example of them is: template <int pinNumber> class InputPin { static bool IsHigh() { return ( (*portAddress) & (1<<pinNumber) ); } }; template <typename InputPin> class Button { static bool IsPressed() { return !InputPin::IsHigh(); } }; This works beautifully and by using class templates, the condition below will compile as tightly as if I'd handwritten it in assembly (a single instruction). Button < InputPin<1> > powerButton; if (powerButton.IsPressed()) ........; However, I am extending it to deal with interrupts and have got a problem with circular references. Compared to the original InputPin, a new InputPinIRQ class has an extra static member function that will be called automatically by the hardware when the pin value changes. I'd like it to be able to notify the Button class of this, so that the Button class can then notify the main application that it has been pressed/released. I am currently doing this with function pointers to callbacks. In order for the callback code to be inlined by the compiler, I need to pass the function pointers as template parameters. So now, both of the new classes have an extra template parameter that is a pointer to a callback function. Unfortunately this gives me a circular reference because to instantiate a ButtonIRQ class I now have to do something like this: ButtonIRQ< InputPinIRQ< A1, ButtonIRQ<....>::OnPinChange, OnButtonChange > pB; where the <...... represents the circular reference. Does anyone know how I can avoid this circular reference? I am new to templates, so might be missing something really simple. It's important that the compiler knows exactly what code will be run when the interrupt occurs as it then does some very useful optimisation - it is able to inline the callback function and literally inserts the callback function's code at the exact address that is called on a h/w interrupt.

    Read the article

  • Custom CSS menu, "Active" tab remains on 'Home' not the actual page

    - by user1690254
    I created this custom css menu, but when switching tabs, the "Active" tab design remains on the 'Home' link on the menu, rather than the actual page I'm on. Any idea how I an fix this? Here's the code: .menu{margin:0 auto; padding:0; height:30px; width:100%; display:block; background:url('http://media.datahc.com/Affiliates/43817/Brands/Image/topmenuimages.png') repeat-x;} .menu li{padding:0; margin:0; list-style:none; display:inline;} .menu li a{float:left; padding-left:15px; display:block; color:rgb(255,255,255); text-decoration:none; font:12px Verdana, Arial, Helvetica, sans-serif; cursor:pointer; background:url('http://media.datahc.com/Affiliates/43817/Brands/Image/topmenuimages.png') 0px -30px no-repeat;} .menu li a span{line-height:30px; float:left; display:block; padding-right:15px; background:url('http://media.datahc.com/Affiliates/43817/Brands/Image/topmenuimages.png') 100% -30px no-repeat;} .menu li a:hover{background-position:0px -60px; color:rgb(255,255,255);} .menu li a:hover span{background-position:100% -60px;} .menu li a.active, .menu li a.active:hover{line-height:30px; font:12px Verdana, Arial, Helvetica, sans-serif; background:url('http://media.datahc.com/Affiliates/43817/Brands/Image/topmenuimages.png') 0px -90px no-repeat; color:rgb(255,255,255);} .menu li a.active span, .menu li a.active:hover span{background:url('http://media.datahc.com/Affiliates/43817/Brands/Image/topmenuimages.png') 100% -90px no-repeat;} <ul class="menu"> <li><a href="http://caribbeantl.com/"; class="active"><span>Home</span></a></li> <li><a href="http://caribbeantl.com/hotels/"><span>Testing post</span></a></li> </ul>

    Read the article

  • Disregard a particular TD element

    - by RussellDias
    Below I have the code that allows me to edit a table row inline. However it edits ALL of the TDs within that row. My problem, along with the code, are stated below. Any help is appreciated. <tbody> <tr> <th scope="row">Test</th> <td class="amount">$124</td> <td class="amount" id="" >$154</td> <td class="diff">- 754</td> </tr> </tbody> The above table is just a sample. What I have been trying to accomplish is, to simply edit the TDs within that particular row, but I need it to disregard the diff TD. I'm fairly new to jQuery and have got the following code via the help of a jQuery book. $(document).ready(function() { TABLE.formwork('#current-expenses'); }); var TABLE = {}; TABLE.formwork = function(table){ var $tables = $(table); $tables.each(function () { var _table = $(this); _table.find('thead tr').append($('<th class="edit">&nbsp;</th>')); _table.find('tbody tr').append($('<td class="edit"><input type="button" value="Edit"/></td>')) }); $tables.find('.edit :button').live('click', function(e) { TABLE.editable(this); e.preventDefault(); }); } TABLE.editable = function(button) { var $button = $(button); var $row = $button.parents('tbody tr'); var $cells = $row.children('td').not('.edit'); if($row.data('flag')) { // in edit mode, move back to table // cell methods $cells.each(function () { var _cell = $(this); _cell.html(_cell.find('input').val()); }) $row.data('flag',false); $button.val('Edit'); } else { // in table mode, move to edit mode // cell methods $cells.each(function() { var _cell = $(this); _cell.data('text', _cell.html()).html(''); if($('td.diff')){ var $input = $('<input type="text" />') .val(_cell.data('text')) .width(_cell.width() - 16); _cell.append($input); } }) $row.data('flag', true); $button.val('Save'); } } I have attempted to alter the code so that it would disregard the diff class TD, but have had no luck so far.

    Read the article

  • need help in positioning

    - by teki
    i am using "beassistance validation" for my form and using tooltip plugin and it work fine except that positioning. please have a look at this link and i upload my form to get an idea what i am talking about. what i want is: if my validation fails i want to display the message after the tooltip icon, but its displaying the message before the tooltip icon. please see here here is the .css i am using: validation .css #aspnetForm { width: 670px; } #aspnetForm label.error { margin-left: 10px; width: auto; display: inline; } form.cmxform { width: 50em; } em.error { background: url("Images/unchecked.gif") no-repeat 0px 0px; padding-left: 16px; } em.success { background: url("Images/checked.gif") no-repeat 0px 0px; padding-left: 16px; } form.cmxform label.error { margin-left: auto; width: 250px; } #aspnetForm label.error { background: url("Images/unchecked.gif") no-repeat 0px 0px; padding-left: 16px; padding-bottom: 2px; font-weight: bold; color: #EA5200; } #aspnetForm label.checked { background: url("Images/checked.gif") no-repeat 0px 0px; } em.error { color: black; } #warning { display: none; } <asp:Label runat="server" ID='Label8' >Start Date:</asp:Label> <asp:TextBox ID="txtStartDate" runat='server' ></asp:TextBox> <a style="cursor: hand" class="tooltip" title="Select the starting date of a visit, example 05/05/2010 (MM/DD/YYYY)!"> <img alt="" src="Scripts/JQuery/Tooltip/icon_tooltip.gif" style="width: 11px; height: 11px" /></a> <p> </p> <asp:Label runat="server" ID='Label9' >End Date:</asp:Label> <asp:TextBox ID="txtEndDate" runat='server' ></asp:TextBox> <a style="cursor: hand" class="tooltip" title="Select the end date of a visit, example 05/06/2010 (MM/DD/YYYY)!"> <img alt="" src="Scripts/JQuery/Tooltip/icon_tooltip.gif" style="width: 11px; height: 11px" /></a> tooltip.css #tooltip{ position:absolute; border:1px solid #333; background:#f7f5d1; padding:2px 5px; color:#333; display:none; }

    Read the article

  • GDI+ Load a jpg and save as 24bit png problem

    - by wookey
    Problem Hello all! I have this code which takes my jpg image loops through altering pixels and finally saving it as a png type. The problem is that the resulting image has a bit depth of 32 bits. I need it to be 24 bit, can any one shiny some light on the correct method of setting it? Am I along the right tracks looking at setting the pixel format to PixelFormat24bppRGB? Code static inline void Brighten(Gdiplus::Bitmap* img) { int width = img->GetWidth()/8,height = img->GetHeight(), max = (width*height),r,g,b; Gdiplus::Color pixel; for(int a = 0,x = 0, y = -1; a < max; ++a) { x = a%width; if(x == 0) ++y; img->GetPixel(x,y,&pixel); r = pixel.GetR(); g = pixel.GetG(); b = pixel.GetB(); if (r > 245) r = 245; if (g > 245) g = 245; if (b > 245) b = 245; r = 10; g = 10; b = 10; pixel = Gdiplus::Color(r,g,b); img->SetPixel(x,y,pixel);; } } ULONG_PTR m_dwToken = 0; Gdiplus::GdiplusStartupInput input; Gdiplus::GdiplusStartupOutput output; Gdiplus::GdiplusStartup( &m_dwToken, &input, &output ); USES_CONVERSION_EX; Gdiplus::ImageCodecInfo* pEncoders = static_cast< Gdiplus::ImageCodecInfo* >( _ATL_SAFE_ALLOCA(1040, _ATL_SAFE_ALLOCA_DEF_THRESHOLD)); Gdiplus::DllExports::GdipGetImageEncoders(5, 1040, pEncoders ); CLSID clsidEncoder = pEncoders[4].Clsid; Gdiplus::Bitmap img1((CT2W)L"IMG_1.JPG"); Brighten(&img1); img1.Save((CT2W)L"IMG_1_R3.PNG",&clsidEncoder,NULL); Thanks in advance!

    Read the article

  • css issue on hover- shaky effect

    - by Sarika Thapaliya
    <style type="text/css"> .linkcontainer{border-right: solid 0.2px white;margin-right:1px} .hardlink{color: #FFF !important; border: 1px solid transparent; } .hardlink:hover{ background:url("/_layouts/images/bgximg.png") repeat-x -0px -489px; display:inline-block; background-color:#21374C; border:0.2px solid #5badff; line-height:20px; text-decoration:none !important;} </style> <div style="padding-bottom:3px;background:transparent; color:white!important; float:left; margin-right:20px; line-height:42px;"> <span class="linkcontainer"> <a class="hardlink" style="padding:0 10px;" href="http://hronline">HROnline</a> </span> <span class="linkcontainer"> <a class="hardlink" style="padding:0 10px; " href="http://hronline/ec">Employee Center</a> </span> <span class="linkcontainer"> <a class="hardlink" style="padding:0 10px; " href="http://hronline/businesscommunities">Business Communities</a> </span> <span class="linkcontainer"> <a class="hardlink" style="padding:0 10px;" href="http://hronline/internalservices">Internal Services</a> </span> <span class="linkcontainer"> <a class="hardlink" style="padding:0 10px;" href="http://hronline/policiesprocedures">Policies&procedures</a> </span> <span class="linkcontainer"> <a class="hardlink" style="padding:0 10px;" href="http://hronline/qualitybestpractices">Best Practices</a> </span> </div> I added a right border to the span that contain menu links. When I hover on each menu links, it also has some background. This is causing jerky effect on the whole container.. What is causing the shaky effect on hover? I don't seem to figure it out--again..

    Read the article

  • jquery Hover and while loop

    - by DragoN
    i have a table of php with while loop to show the records i added a jquery hover to do that : if hovered it show a message in same row but the problem is : if hover it show a message in all rows here is css: <style> .tansa{ position: absolute; margin-right: -60px; margin-top:-25px; background: #CBDFF3; border: 1px solid #4081C3; font-size: 0.88em; padding: 2px 7px; display: inline-block; border-radius: 8px; -moz-border-radius: 8px; -webkit-border-radius: 8px; line-height: 1.2em; text-shadow: 0 0 0em #FFF; overflow: hidden; text-align: center; color:black; display:none; } .arrow{ position: relative; width: 0; height: 0; top: -25px; border-top: 5px solid #000000; border-right: 5px solid transparent; border-left: 5px solid transparent; display:none; } </style> here is my php : <table><tr>row</tr> <?php $results = mysql_query("select * from MyTable"); while{$r = mysql_fetch_array($results)){ echo "<tr><td>Row : <img src='img/tans.png' width='24' height='24' class='tansef' /><span class='tansa' >the message</span><div class='arrow'></div></td></tr>"; } ?> </table> here is jquery $(document).ready(function(){ $('.tansef').hover(function(){ var sh = $('.tansa'); var sharrow = $('.arrow'); sh.show(); sharrow.show(); },function(){ var shs = $('.tansa'); var sharrows = $('.arrow'); shs.hide(); sharrows.hide(); }); }); any solution to show the message in each row only

    Read the article

  • allignment issue of div tag

    - by Quasar the space thing
    I am trying to create a web page where on click of a button I can add div tags. What I thought to do was that I'll create two div tags within a single div so that over all presentation will be uniform and similar to a table having two columns and multiple rows and the first column contains only label's and second column will contain textbox. Here is the JS file : var counter = 0; function create_div(type){ var dynDiv = document.createElement("div"); dynDiv.id = "divid_"+counter; dynDiv.class="main"; document.body.appendChild(dynDiv); question(); if(type == 'ADDTEXTBOX'){ ADDTEXTBOX(); } counter=counter+1; } function question(){ var question_div = document.createElement("div"); question_div.class="question"; question_div.id = "question_div_"+counter; var Question = prompt("Enter The Question here:", ""); var node=document.createTextNode(Question); question_div.appendChild(node); var element=document.getElementById("divid_"+counter); element.appendChild(question_div); } function ADDTEXTBOX(){ var answer_div = document.createElement("div"); answer_div.class="answer"; answer_div.id = "answer_div_"+counter; var answer_tag = document.createElement("input"); answer_tag.id = "answer_tag_"+counter; answer_tag.setAttribute("type", "text"); answer_tag.setAttribute("name", "textbox"); answer_div.appendChild(answer_tag); var element=document.getElementById("divid_"+counter); element.appendChild(answer_div); } Here is the css file : .question { width: 40%; height: auto; float: left; display: inline-block; text-align: justify; word-wrap:break-word; } .answer { padding-left:10%; width: 40%; height: auto; float: left; overflow: auto; word-wrap:break-word; } .main { width: auto; background-color:gray; height: auto; overflow: auto; word-wrap:break-word; } My problem is that the code is working properly but both the divisions are not coming in a straight line. after the first div prints on the screen the second divisions comes in another line. How can I make both the div's come in the same line ? Thank You. PS : should I stick with the current idea of using div or should I try some other approach ? like tables ?

    Read the article

  • Tooltip arrow right

    - by Tabatha M
    I'm trying to make this tooltip arrow point to the right towards the link. CSS .tooltipside { position: relative; cursor: help; display: inline-block; outline: none; } .tooltipside span { visibility: hidden; position: absolute; bottom: -22px; z-index: 999; width: 52px; margin-left: -63px; padding: 2px; border: 1px solid #80a7ba; background-color: white; -moz-border-radius: 4px; border-radius: 4px; -moz-box-shadow: 0 1px 2px rgba(0,0,0,.4), 0 1px 0 rgba(255,255,255,.5) inset; -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.4), 0 1px 0 rgba(255,255,255,.5) inset; box-shadow: 0 1px 2px rgba(0,0,0,.4), 0 1px 0 rgba(255,255,255,.5) inset; text-shadow: 0 1px 0 rgba(255,255,255,.4); } .tooltipside:hover { border: 0; /* IE6 fix */ } .tooltipside:hover span { visibility: visible; } .tooltipside span:before, .tooltipside span:after { content: ""; position: absolute; z-index: 1000; bottom: -7px; left: 50%; margin-left: -8px; border-top: 8px solid #80a7ba; border-left: 8px solid transparent; border-right: 8px solid transparent; border-bottom: 0; } .tooltipside span:before { border-top-color: #ccc; bottom: -8px; } ? The html is <a href='#' class='tooltipside'><span> <img src='http://cdn2.iconfinder.com/data/icons/32pxmania/misc_57.png' border='0' width='52' height='52'></span>LINK</a> TEST TEST TEST</b>? It currently points down in the center of the tooltip I need it to point right towards the link. How would I do this? Thanks

    Read the article

  • Dynamic JSON Parsing in .NET with JsonValue

    - by Rick Strahl
    So System.Json has been around for a while in Silverlight, but it's relatively new for the desktop .NET framework and now moving into the lime-light with the pending release of ASP.NET Web API which is bringing a ton of attention to server side JSON usage. The JsonValue, JsonObject and JsonArray objects are going to be pretty useful for Web API applications as they allow you dynamically create and parse JSON values without explicit .NET types to serialize from or into. But even more so I think JsonValue et al. are going to be very useful when consuming JSON APIs from various services. Yes I know C# is strongly typed, why in the world would you want to use dynamic values? So many times I've needed to retrieve a small morsel of information from a large service JSON response and rather than having to map the entire type structure of what that service returns, JsonValue actually allows me to cherry pick and only work with the values I'm interested in, without having to explicitly create everything up front. With JavaScriptSerializer or DataContractJsonSerializer you always need to have a strong type to de-serialize JSON data into. Wouldn't it be nice if no explicit type was required and you could just parse the JSON directly using a very easy to use object syntax? That's exactly what JsonValue, JsonObject and JsonArray accomplish using a JSON parser and some sweet use of dynamic sauce to make it easy to access in code. Creating JSON on the fly with JsonValue Let's start with creating JSON on the fly. It's super easy to create a dynamic object structure. JsonValue uses the dynamic  keyword extensively to make it intuitive to create object structures and turn them into JSON via dynamic object syntax. Here's an example of creating a music album structure with child songs using JsonValue:[TestMethod] public void JsonValueOutputTest() { // strong type instance var jsonObject = new JsonObject(); // dynamic expando instance you can add properties to dynamic album = jsonObject; album.AlbumName = "Dirty Deeds Done Dirt Cheap"; album.Artist = "AC/DC"; album.YearReleased = 1977; album.Songs = new JsonArray() as dynamic; dynamic song = new JsonObject(); song.SongName = "Dirty Deeds Done Dirt Cheap"; song.SongLength = "4:11"; album.Songs.Add(song); song = new JsonObject(); song.SongName = "Love at First Feel"; song.SongLength = "3:10"; album.Songs.Add(song); Console.WriteLine(album.ToString()); } This produces proper JSON just as you would expect: {"AlbumName":"Dirty Deeds Done Dirt Cheap","Artist":"AC\/DC","YearReleased":1977,"Songs":[{"SongName":"Dirty Deeds Done Dirt Cheap","SongLength":"4:11"},{"SongName":"Love at First Feel","SongLength":"3:10"}]} The important thing about this code is that there's no explicitly type that is used for holding the values to serialize to JSON. I am essentially creating this value structure on the fly by adding properties and then serialize it to JSON. This means this code can be entirely driven at runtime without compile time restraints of structure for the JSON output. Here I use JsonObject() to create a new object and immediately cast it to dynamic. JsonObject() is kind of similar in behavior to ExpandoObject in that it allows you to add properties by simply assigning to them. Internally, JsonValue/JsonObject these values are stored in pseudo collections of key value pairs that are exposed as properties through the DynamicObject functionality in .NET. The syntax gets a little tedious only if you need to create child objects or arrays that have to be explicitly defined first. Other than that the syntax looks like normal object access sytnax. Always remember though these values are dynamic - which means no Intellisense and no compiler type checking. It's up to you to ensure that the values you create are accessed consistently and without typos in your code. Note that you can also access the JsonValue instance directly and get access to the underlying type. This means you can assign properties by string, which can be useful for fully data driven JSON generation from other structures. Below you can see both styles of access next to each other:// strong type instance var jsonObject = new JsonObject(); // you can explicitly add values here jsonObject.Add("Entered", DateTime.Now); // expando style instance you can just 'use' properties dynamic album = jsonObject; album.AlbumName = "Dirty Deeds Done Dirt Cheap"; JsonValue internally stores properties keys and values in collections and you can iterate over them at runtime. You can also manipulate the collections if you need to to get the object structure to look exactly like you want. Again, if you've used ExpandoObject before JsonObject/Value are very similar in the behavior of the structure. Reading JSON strings into JsonValue The JsonValue structure supports importing JSON via the Parse() and Load() methods which can read JSON data from a string or various streams respectively. Essentially JsonValue includes the core JSON parsing to turn a JSON string into a collection of JsonValue objects that can be then referenced using familiar dynamic object syntax. Here's a simple example:[TestMethod] public void JsonValueParsingTest() { var jsonString = @"{""Name"":""Rick"",""Company"":""West Wind"",""Entered"":""2012-03-16T00:03:33.245-10:00""}"; dynamic json = JsonValue.Parse(jsonString); // values require casting string name = json.Name; string company = json.Company; DateTime entered = json.Entered; Assert.AreEqual(name, "Rick"); Assert.AreEqual(company, "West Wind"); } The JSON string represents an object with three properties which is parsed into a JsonValue object and cast to dynamic. Once cast to dynamic I can then go ahead and access the object using familiar object syntax. Note that the actual values - json.Name, json.Company, json.Entered - are actually of type JsonPrimitive and I have to assign them to their appropriate types first before I can do type comparisons. The dynamic properties will automatically cast to the right type expected as long as the compiler can resolve the type of the assignment or usage. The AreEqual() method oesn't as it expects two object instances and comparing json.Company to "West Wind" is comparing two different types (JsonPrimitive to String) which fails. So the intermediary assignment is required to make the test pass. The JSON structure can be much more complex than this simple example. Here's another example of an array of albums serialized to JSON and then parsed through with JsonValue():[TestMethod] public void JsonArrayParsingTest() { var jsonString = @"[ { ""Id"": ""b3ec4e5c"", ""AlbumName"": ""Dirty Deeds Done Dirt Cheap"", ""Artist"": ""AC/DC"", ""YearReleased"": 1977, ""Entered"": ""2012-03-16T00:13:12.2810521-10:00"", ""AlbumImageUrl"": ""http://ecx.images-amazon.com/images/I/61kTaH-uZBL._AA115_.jpg"", ""AmazonUrl"": ""http://www.amazon.com/gp/product/B00008BXJ4/ref=as_li_ss_tl?ie=UTF8&tag=westwindtechn-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=B00008BXJ4"", ""Songs"": [ { ""AlbumId"": ""b3ec4e5c"", ""SongName"": ""Dirty Deeds Done Dirt Cheap"", ""SongLength"": ""4:11"" }, { ""AlbumId"": ""b3ec4e5c"", ""SongName"": ""Love at First Feel"", ""SongLength"": ""3:10"" }, { ""AlbumId"": ""b3ec4e5c"", ""SongName"": ""Big Balls"", ""SongLength"": ""2:38"" } ] }, { ""Id"": ""67280fb8"", ""AlbumName"": ""Echoes, Silence, Patience & Grace"", ""Artist"": ""Foo Fighters"", ""YearReleased"": 2007, ""Entered"": ""2012-03-16T00:13:12.2810521-10:00"", ""AlbumImageUrl"": ""http://ecx.images-amazon.com/images/I/41mtlesQPVL._SL500_AA280_.jpg"", ""AmazonUrl"": ""http://www.amazon.com/gp/product/B000UFAURI/ref=as_li_ss_tl?ie=UTF8&tag=westwindtechn-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=B000UFAURI"", ""Songs"": [ { ""AlbumId"": ""67280fb8"", ""SongName"": ""The Pretender"", ""SongLength"": ""4:29"" }, { ""AlbumId"": ""67280fb8"", ""SongName"": ""Let it Die"", ""SongLength"": ""4:05"" }, { ""AlbumId"": ""67280fb8"", ""SongName"": ""Erase/Replay"", ""SongLength"": ""4:13"" } ] }, { ""Id"": ""7b919432"", ""AlbumName"": ""End of the Silence"", ""Artist"": ""Henry Rollins Band"", ""YearReleased"": 1992, ""Entered"": ""2012-03-16T00:13:12.2800521-10:00"", ""AlbumImageUrl"": ""http://ecx.images-amazon.com/images/I/51FO3rb1tuL._SL160_AA160_.jpg"", ""AmazonUrl"": ""http://www.amazon.com/End-Silence-Rollins-Band/dp/B0000040OX/ref=sr_1_5?ie=UTF8&qid=1302232195&sr=8-5"", ""Songs"": [ { ""AlbumId"": ""7b919432"", ""SongName"": ""Low Self Opinion"", ""SongLength"": ""5:24"" }, { ""AlbumId"": ""7b919432"", ""SongName"": ""Grip"", ""SongLength"": ""4:51"" } ] } ]"; dynamic albums = JsonValue.Parse(jsonString); foreach (dynamic album in albums) { Console.WriteLine(album.AlbumName + " (" + album.YearReleased.ToString() + ")"); foreach (dynamic song in album.Songs) { Console.WriteLine("\t" + song.SongName ); } } Console.WriteLine(albums[0].AlbumName); Console.WriteLine(albums[0].Songs[1].SongName);}   It's pretty sweet how easy it becomes to parse even complex JSON and then just run through the object using object syntax, yet without an explicit type in the mix. In fact it looks and feels a lot like if you were using JavaScript to parse through this data, doesn't it? And that's the point…© Rick Strahl, West Wind Technologies, 2005-2012Posted in .NET  Web Api  JSON   Tweet !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs"); (function() { var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; po.src = 'https://apis.google.com/js/plusone.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s); })();

    Read the article

  • data validation on wpf passwordbox:type password, re-type password

    - by black sensei
    Hello Experts !! I've built a wpf windows application in with there is a registration form. Using IDataErrorInfo i could successfully bind the field to a class property and with the help of styles display meaningful information about the error to users.About the submit button i use the MultiDataTrigger with conditions (Based on a post here on stackoverflow).All went well. Now i need to do the same for the passwordbox and apparently it's not as straight forward.I found on wpftutorial an article and gave it a try but for some reason it wasn't working. i've tried another one from functionalfun. And in this Functionalfun case the properties(databind,databound) are not recognized as dependencyproperty even after i've changed their name as suggested somewhere in the comments plus i don't have an idea whether it will work for a windows application, since it's designed for web. to give you an idea here is some code on textboxes <Window.Resources> <data:General x:Key="recharge" /> <Style x:Key="validButton" TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}" > <Setter Property="IsEnabled" Value="False"/> <Style.Triggers> <MultiDataTrigger> <MultiDataTrigger.Conditions> <Condition Binding="{Binding ElementName=txtRecharge, Path=(Validation.HasError)}" Value="false" /> </MultiDataTrigger.Conditions> <Setter Property="IsEnabled" Value="True" /> </MultiDataTrigger> </Style.Triggers> </Style> <Style x:Key="txtboxerrors" TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}"> <Style.Triggers> <Trigger Property="Validation.HasError" Value="true"> <Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}"/> <Setter Property="Validation.ErrorTemplate"> <Setter.Value> <ControlTemplate> <DockPanel LastChildFill="True"> <TextBlock DockPanel.Dock="Bottom" FontSize="8" FontWeight="ExtraBold" Foreground="red" Padding="5 0 0 0" Text="{Binding ElementName=showerror, Path=AdornedElement.(Validation.Errors)[0].ErrorContent}"></TextBlock> <Border BorderBrush="Red" BorderThickness="2"> <AdornedElementPlaceholder Name="showerror" /> </Border> </DockPanel> </ControlTemplate> </Setter.Value> </Setter> </Trigger> </Style.Triggers> </Style> </Window.Resources> <TextBox Margin="12,69,12,70" Name="txtRecharge" Style="{StaticResource txtboxerrors}"> <TextBox.Text> <Binding Path="Field" Source="{StaticResource recharge}" ValidatesOnDataErrors="True" UpdateSourceTrigger="PropertyChanged"> <Binding.ValidationRules> <ExceptionValidationRule /> </Binding.ValidationRules> </Binding> </TextBox.Text> </TextBox> <Button Height="23" Margin="98,0,0,12" Name="btnRecharge" VerticalAlignment="Bottom" Click="btnRecharge_Click" HorizontalAlignment="Left" Width="75" Style="{StaticResource validButton}">Recharge</Button> some C# : class General : IDataErrorInfo { private string _field; public string this[string columnName] { get { string result = null; if(columnName == "Field") { if(Util.NullOrEmtpyCheck(this._field)) { result = "Field cannot be Empty"; } } return result; } } public string Error { get { return null; } } public string Field { get { return _field; } set { _field = value; } } } So what are suggestion you guys have for me? I mean how would you go about this? how do you do this since the databinding first purpose here is not to load data onto the fields they are just (for now) for data validation. thanks for reading this.

    Read the article

  • WPF Templates error - "Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension' threw

    - by jasonk
    I've just started experimenting with WPF templates vs. styles and I'm not sure what I'm doing wrong. The goal below is to alternate the colors of the options in the menu. The code works fine with just the , but when I copy and paste/rename it for the second segment of "MenuChoiceOdd" I get the following error: Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception. Sample of the code: <Window x:Class="WpfApplication1.Template_Testing" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Template_Testing" Height="300" Width="300"> <Grid> <Grid.Resources> <ControlTemplate x:Key="MenuChoiceEven"> <Border BorderThickness="1" BorderBrush="#FF4A5D80"> <TextBlock Height="Auto" HorizontalAlignment="Stretch" Margin="0" Width="Auto" FontSize="14" Foreground="SlateGray" TextAlignment="Left" AllowDrop="True" Text="{Binding Path=Content, RelativeSource={RelativeSource TemplatedParent}}"> <TextBlock.Background> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="White" Offset="0" /> <GradientStop Color="#FFC2CCDB" Offset="1" /> </LinearGradientBrush> </TextBlock.Background> </TextBlock> </Border> </ControlTemplate> <ControlTemplate x:Key="MenuChoiceOdd"> <Border BorderThickness="1" BorderBrush="#FF4A5D80"> <TextBlock Height="Auto" HorizontalAlignment="Stretch" Margin="0" Width="Auto" FontSize="14" Foreground="SlateGray" TextAlignment="Left" AllowDrop="True" Text="{Binding Path=Content, RelativeSource={RelativeSource TemplatedParent}}"> <TextBlock.Background> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="White" Offset="0" /> <GradientStop Color="##FFCBCBCB" Offset="1" /> </LinearGradientBrush> </TextBlock.Background> </TextBlock> </Border> </ControlTemplate> </Grid.Resources> <Border BorderBrush="SlateGray" BorderThickness="2" Margin="10" CornerRadius="10" Background="LightSteelBlue" Width="200"> <StackPanel Margin="4"> <TextBlock Height="Auto" HorizontalAlignment="Stretch" Margin="2,2,2,0" Name="MenuHeaderTextBlock" Text="TextBlock" Width="Auto" FontSize="16" Foreground="PaleGoldenrod" TextAlignment="Left" Padding="10" FontWeight="Bold"><TextBlock.Background><LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"><GradientStop Color="LightSlateGray" Offset="0" /><GradientStop Color="DarkSlateGray" Offset="1" /></LinearGradientBrush></TextBlock.Background></TextBlock> <StackPanel Height="Auto" HorizontalAlignment="Stretch" Margin="2,0,2,0" Name="MenuChoicesStackPanel" VerticalAlignment="Top" Width="Auto"> <Button Template="{StaticResource MenuChoiceEven}" Content="Test Even menu element" /> <Button Template="{StaticResource MenuChoiceOdd}" Content="Test odd menu element" /> </StackPanel> </StackPanel> </Border> </Grid> </Window> What am I doing wrong?

    Read the article

< Previous Page | 112 113 114 115 116 117 118 119 120 121 122 123  | Next Page >