You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by mcfly37 <vi...@gmail.com> on 2010/07/28 18:00:53 UTC

Background-color dynamic change

Hi all!!

As I said in the title I'm trying to change dynamically the background-color
parameter of a <div>. I tried with this code :

<div t:type="loop" t:source="instanceList" t:value="instances">
		  	<div id="Liste" t:source="instanceState" t:value="color"
style="background-color: ${color}">
		  		
		  			${instances.nomInstance}
		  	</div>
		  </div>

And the java class is like this :

	@Property
	private Instances instances;
	
	@Property
	private String color;

public List<Instances> getInstanceList()
	{
		try {
			return (List<Instances>) instanceManager.sortAll();
		} catch (BusinessException e) {
			
			e.printStackTrace();
			return null;
		} catch (TechnicalException e) {
			
			e.printStackTrace();
			return null;
		} 
	}
	
	public String getInstanceState()
	{
		InstanceService service = new InstanceService(); 
		color = service.instanceState(instances.getIdAo());
		return color;
	}

Apparently it's good but the background-color doesn't change... Even if I
try to simply return color = "red" there are no changes... and neither error
message... So I'm quite disappointed, I don't see where the program bugs...

If anyone can help me it would be very great ^^

ps : Excuse me for the grammar, English is not my native language ^^
-- 
View this message in context: http://old.nabble.com/Background-color-dynamic-change-tp29288115p29288115.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Background-color dynamic change

Posted by mcfly37 <vi...@gmail.com>.
Hello

Thanks, that was the problem indeed. So I change to that :

		<div t:type="loop" t:source="instanceList" t:value="instances">
		  	<div id="Liste" style="background-color: ${getInstanceState()}">
		  		
		  			${instances.nomInstance}
		  	</div>
		  </div>

And it works!!!!!

But now I have another problem (yeahh I never stop ^^) with my service this
time. Here is the service class :

@Inject
	@Service("borneManager")
	private BorneManager borneManager;

	private IsoMsgServiceImpl service;

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.atosworldline.effia.applira.web.services.BorneService#borneState(
	 * long)
	 */
	public String borneState(long id) {
		List<Bornes> bornes = null;
		service = new IsoMsgServiceImpl();
		String color = "green";
		try {
			bornes = (List<Bornes>) borneManager.findByIdAo(id);
		} catch (BusinessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (TechnicalException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		for (Bornes borne : bornes) {
			String colorBorne = service.borneStateForInstance(borne.getId());
			if (color == "green") {

				color = colorBorne;
			} else if (color == "orange") {
				if (colorBorne != "green") {
					color = colorBorne;
				}
			} else if (color == "red") {
				return color;
			}

		}
		return color;
	}

But when I try to run it, my borneManager bean is not injected as in the
page class...

I don't really see were is the problem.


mcfly37 wrote:
> 
> Hi all!!
> 
> As I said in the title I'm trying to change dynamically the
> background-color parameter of a <div>. I tried with this code :
> 
> <div t:type="loop" t:source="instanceList" t:value="instances">
> 		  	<div id="Liste" t:source="instanceState" t:value="color"
> style="background-color: ${color}">
> 		  		
> 		  			${instances.nomInstance}
> 		  	</div>
> 		  </div>
> 
> And the java class is like this :
> 
> 	@Property
> 	private Instances instances;
> 	
> 	@Property
> 	private String color;
> 
> public List<Instances> getInstanceList()
> 	{
> 		try {
> 			return (List<Instances>) instanceManager.sortAll();
> 		} catch (BusinessException e) {
> 			
> 			e.printStackTrace();
> 			return null;
> 		} catch (TechnicalException e) {
> 			
> 			e.printStackTrace();
> 			return null;
> 		} 
> 	}
> 	
> 	public String getInstanceState()
> 	{
> 		InstanceService service = new InstanceService(); 
> 		color = service.instanceState(instances.getIdAo());
> 		return color;
> 	}
> 
> Apparently it's good but the background-color doesn't change... Even if I
> try to simply return color = "red" there are no changes... and neither
> error message... So I'm quite disappointed, I don't see where the program
> bugs...
> 
> If anyone can help me it would be very great ^^
> 
> ps : Excuse me for the grammar, English is not my native language ^^
> 

-- 
View this message in context: http://old.nabble.com/Background-color-dynamic-change-tp29288115p29295649.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Background-color dynamic change

Posted by Michael Gentry <mg...@masslight.net>.
I don't believe your getInstanceState() method is being called,
therefore you are not setting your color.  You have:

 <div id="Liste" t:source="instanceState" t:value="color"
style="background-color: ${color}">

Tapestry is ignoring the t:source because there is no t:type
specified.  If you look at the HTML generated, you'll probably see:

<div id="Liste" style="background-color: ">


mrg


On Wed, Jul 28, 2010 at 12:00 PM, mcfly37 <vi...@gmail.com> wrote:
>
> Hi all!!
>
> As I said in the title I'm trying to change dynamically the background-color
> parameter of a <div>. I tried with this code :
>
> <div t:type="loop" t:source="instanceList" t:value="instances">
>                        <div id="Liste" t:source="instanceState" t:value="color"
> style="background-color: ${color}">
>
>                                        ${instances.nomInstance}
>                        </div>
>                  </div>
>
> And the java class is like this :
>
>        @Property
>        private Instances instances;
>
>        @Property
>        private String color;
>
> public List<Instances> getInstanceList()
>        {
>                try {
>                        return (List<Instances>) instanceManager.sortAll();
>                } catch (BusinessException e) {
>
>                        e.printStackTrace();
>                        return null;
>                } catch (TechnicalException e) {
>
>                        e.printStackTrace();
>                        return null;
>                }
>        }
>
>        public String getInstanceState()
>        {
>                InstanceService service = new InstanceService();
>                color = service.instanceState(instances.getIdAo());
>                return color;
>        }
>
> Apparently it's good but the background-color doesn't change... Even if I
> try to simply return color = "red" there are no changes... and neither error
> message... So I'm quite disappointed, I don't see where the program bugs...
>
> If anyone can help me it would be very great ^^
>
> ps : Excuse me for the grammar, English is not my native language ^^
> --
> View this message in context: http://old.nabble.com/Background-color-dynamic-change-tp29288115p29288115.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Background-color dynamic change

Posted by mcfly37 <vi...@gmail.com>.
Problem solved!! I just had to declare my service in appModule class and
inject it in my pages's pojo

Thanks for the help !!!



mcfly37 wrote:
> 
> Hi all!!
> 
> As I said in the title I'm trying to change dynamically the
> background-color parameter of a <div>. I tried with this code :
> 
> <div t:type="loop" t:source="instanceList" t:value="instances">
> 		  	<div id="Liste" t:source="instanceState" t:value="color"
> style="background-color: ${color}">
> 		  		
> 		  			${instances.nomInstance}
> 		  	</div>
> 		  </div>
> 
> And the java class is like this :
> 
> 	@Property
> 	private Instances instances;
> 	
> 	@Property
> 	private String color;
> 
> public List<Instances> getInstanceList()
> 	{
> 		try {
> 			return (List<Instances>) instanceManager.sortAll();
> 		} catch (BusinessException e) {
> 			
> 			e.printStackTrace();
> 			return null;
> 		} catch (TechnicalException e) {
> 			
> 			e.printStackTrace();
> 			return null;
> 		} 
> 	}
> 	
> 	public String getInstanceState()
> 	{
> 		InstanceService service = new InstanceService(); 
> 		color = service.instanceState(instances.getIdAo());
> 		return color;
> 	}
> 
> Apparently it's good but the background-color doesn't change... Even if I
> try to simply return color = "red" there are no changes... and neither
> error message... So I'm quite disappointed, I don't see where the program
> bugs...
> 
> If anyone can help me it would be very great ^^
> 
> ps : Excuse me for the grammar, English is not my native language ^^
> 

-- 
View this message in context: http://old.nabble.com/Background-color-dynamic-change-tp29288115p29296385.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org